[Lldb-commits] [lldb] r178726 - <rdar://problem/13198919>

Greg Clayton gclayton at apple.com
Wed Apr 3 18:01:35 PDT 2013


Author: gclayton
Date: Wed Apr  3 20:01:35 2013
New Revision: 178726

URL: http://llvm.org/viewvc/llvm-project?rev=178726&view=rev
Log:
<rdar://problem/13198919>

Try and reap process when sending the "k" packet to avoid a race condition. We now wait for at most 1 second to reap the child process that we are killing.


Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=178726&r1=178725&r2=178726&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Wed Apr  3 20:01:35 2013
@@ -390,6 +390,21 @@ MachProcess::Kill (const struct timespec
     DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Kill() DoSIGSTOP() ::ptrace (PT_KILL, pid=%u, 0, 0) => 0x%8.8x (%s)", m_pid, err.Error(), err.AsString());
     m_thread_actions = DNBThreadResumeActions (eStateRunning, 0);
     PrivateResume ();
+    
+    // Try and reap the process without touching our m_events since
+    // we want the code above this to still get the eStateExited event
+    const uint32_t reap_timeout_usec = 1000000;    // Wait 1 second and try to reap the process
+    const uint32_t reap_interval_usec = 10000;  //
+    uint32_t reap_time_elapsed;
+    for (reap_time_elapsed = 0;
+         reap_time_elapsed < reap_timeout_usec;
+         reap_time_elapsed += reap_interval_usec)
+    {
+        if (GetState() == eStateExited)
+            break;
+        usleep(reap_interval_usec);
+    }
+    DNBLog ("Waited %u ms for process to be reaped (state = %s)", reap_time_elapsed/1000, DNBStateAsString(GetState()));
     return true;
 }
 





More information about the lldb-commits mailing list