Bug 1314466 - part 3, Fennec child processes are no longer forked so kill and waitpid do not work as expected and must gracefully handle error cases. r=billm
authorRandall Barker <rbarker@mozilla.com>
Tue, 18 Oct 2016 13:12:20 -0700
changeset 322465 d6e36e11cfa3700f172c731fb5c899f64446cab4
parent 322464 03696808ec58e6f5751af75ac9030de2349d64b8
child 322466 524f33fa66c6dc47c084c68aa777ff09ea0c804b
push id83882
push userrbarker@mozilla.com
push dateTue, 15 Nov 2016 00:45:54 +0000
treeherdermozilla-inbound@33d7c7b42d7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1314466
milestone52.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 1314466 - part 3, Fennec child processes are no longer forked so kill and waitpid do not work as expected and must gracefully handle error cases. r=billm
ipc/chromium/src/base/process_util_posix.cc
--- a/ipc/chromium/src/base/process_util_posix.cc
+++ b/ipc/chromium/src/base/process_util_posix.cc
@@ -65,25 +65,33 @@ ProcessId GetProcId(ProcessHandle proces
 }
 
 // Attempts to kill the process identified by the given process
 // entry structure.  Ignores specified exit_code; posix can't force that.
 // Returns true if this is successful, false otherwise.
 bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) {
   bool result = kill(process_id, SIGTERM) == 0;
 
+  if (!result && (errno == ESRCH)) {
+    result = true;
+    wait = false;
+  }
+
   if (result && wait) {
     int tries = 60;
     bool exited = false;
     // The process may not end immediately due to pending I/O
     while (tries-- > 0) {
       int pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG));
       if (pid == process_id) {
         exited = true;
         break;
+      } else if (errno == ECHILD) {
+        exited = true;
+        break;
       }
 
       sleep(1);
     }
 
     if (!exited) {
       result = kill(process_id, SIGKILL) == 0;
     }