Fixed a few m_private_run_lock issues when attaching and also fixed the process to not try to restart the process if the process is exited, crashed or detached. Partial patch from Carlo Kok.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179738 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index 6a39442..c973a50 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -2955,6 +2955,7 @@
                 {
                     if (m_public_run_lock.WriteTryLock())
                     {
+                        m_private_run_lock.WriteLock();
                         m_should_detach = true;
                         SetPublicState (eStateAttaching);
                         // Now attach using these arguments.
@@ -3032,6 +3033,7 @@
 
             if (m_public_run_lock.WriteTryLock())
             {
+                m_private_run_lock.WriteLock();
                 // Now attach using these arguments.
                 m_should_detach = true;
                 SetPublicState (eStateAttaching);
@@ -4086,8 +4088,11 @@
             }
         }
 
-        
-        if (m_process_sp->GetPrivateState() != eStateRunning)
+        const lldb::StateType state = m_process_sp->GetPrivateState();
+        if (state != eStateRunning &&
+            state != eStateCrashed &&
+            state != eStateDetached &&
+            state != eStateExited)
         {
             if (!still_should_stop)
             {