Bug 1122303 - nsIProcess::Run needs to handle EINTR on Mac (r=nfroyd)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 16 Jan 2015 09:57:33 -0800
changeset 224296 68b90a5407b2357565d2804028e6abd135ae4a15
parent 224295 8c6cbca7251a822c51441f837dd085071bb010e8
child 224297 dff2539946b2e870923759e1bfd39212fa267469
push id28122
push userkwierso@gmail.com
push dateSat, 17 Jan 2015 01:33:15 +0000
treeherdermozilla-central@369a8f14ccf8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnfroyd
bugs1122303
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1122303 - nsIProcess::Run needs to handle EINTR on Mac (r=nfroyd)
xpcom/threads/nsProcessCommon.cpp
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -32,16 +32,17 @@
 #include "nsString.h"
 #include "nsLiteralString.h"
 #include "nsReadableUtils.h"
 #else
 #ifdef XP_MACOSX
 #include <crt_externs.h>
 #include <spawn.h>
 #include <sys/wait.h>
+#include <sys/errno.h>
 #endif
 #include <sys/types.h>
 #include <signal.h>
 #endif
 
 using namespace mozilla;
 
 #ifdef XP_MACOSX
@@ -259,17 +260,21 @@ nsProcess::Monitor(void* aArg)
     if (process->mShutdown) {
       return;
     }
   }
 #else
 #ifdef XP_MACOSX
   int exitCode = -1;
   int status = 0;
-  if (waitpid(process->mPid, &status, 0) == process->mPid) {
+  pid_t result;
+  do {
+    result = waitpid(process->mPid, &status, 0);
+  } while (result == -1 && errno == EINTR);
+  if (result == process->mPid) {
     if (WIFEXITED(status)) {
       exitCode = WEXITSTATUS(status);
     } else if (WIFSIGNALED(status)) {
       exitCode = 256; // match NSPR's signal exit status
     }
   }
 #else
   int32_t exitCode = -1;