Allow debugserver to detach from the target if the connection is 
unexpectedly closed.

llvm-svn: 202110
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index c69b32e..c077f9b 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -307,14 +307,16 @@
 }
 
 void
-MachProcess::Clear()
+MachProcess::Clear(bool detaching)
 {
     // Clear any cached thread list while the pid and task are still valid
 
     m_task.Clear();
     // Now clear out all member variables
     m_pid = INVALID_NUB_PROCESS;
-    CloseChildFileDescriptors();
+    if (!detaching)
+        CloseChildFileDescriptors();
+        
     m_path.clear();
     m_args.clear();
     SetState(eStateUnloaded);
@@ -554,7 +556,8 @@
     m_task.Clear();
 
     // Clear out any notion of the process we once were
-    Clear();
+    const bool detaching = true;
+    Clear(detaching);
 
     SetState(eStateDetached);
 
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
index 7a52eaa..5fa5dbd 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -258,7 +258,7 @@
         eMachProcessFlagsAttached = (1 << 0),
         eMachProcessFlagsUsingSBS = (1 << 1)
     };
-    void                    Clear ();
+    void                    Clear (bool detaching = false);
     void                    ReplyToAllExceptions ();
     void                    PrivateResume ();