[llvm] r211918 - lldb can interrupt waitpid, so EINTR shouldn't be an error. This fixes the case

Julien Lerouge jlerouge at apple.com
Fri Jun 27 11:02:54 PDT 2014


Author: jlerouge
Date: Fri Jun 27 13:02:54 2014
New Revision: 211918

URL: http://llvm.org/viewvc/llvm-project?rev=211918&view=rev
Log:
lldb can interrupt waitpid, so EINTR shouldn't be an error. This fixes the case
where there is no timeout. In the case where there is a timeout though, the
code is still wrong since it doesn't check that the alarm really went off.

Without this patch, I cannot debug a program that forks itself using
sys::ExecuteAndWait with lldb.

Modified:
    llvm/trunk/lib/Support/Unix/Program.inc

Modified: llvm/trunk/lib/Support/Unix/Program.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Program.inc?rev=211918&r1=211917&r2=211918&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Program.inc (original)
+++ llvm/trunk/lib/Support/Unix/Program.inc Fri Jun 27 13:02:54 2014
@@ -350,7 +350,11 @@ ProcessInfo sys::Wait(const ProcessInfo
   // Parent process: Wait for the child process to terminate.
   int status;
   ProcessInfo WaitResult;
-  WaitResult.Pid = waitpid(ChildPid, &status, WaitPidOptions);
+
+  do {
+    WaitResult.Pid = waitpid(ChildPid, &status, WaitPidOptions);
+  } while (WaitUntilTerminates && WaitResult.Pid == -1 && errno == EINTR);
+
   if (WaitResult.Pid != PI.Pid) {
     if (WaitResult.Pid == 0) {
       // Non-blocking wait.





More information about the llvm-commits mailing list