Backed out changeset 2fc5715105a2 due to bug 1524496. r=me
authorRobert Strong <robert.bugzilla@gmail.com>
Sat, 02 Feb 2019 23:01:23 -0800
changeset 456581 a2168937e103c506b88a3486e21f0739a673e358
parent 456580 bc6d44d38030f2411519d96ecb5c3d2a2c9548a3
child 456582 1b713c9f40d5817de78f88ac3414cc90bf7531f4
push id35491
push useraiakab@mozilla.com
push dateSun, 03 Feb 2019 09:51:48 +0000
treeherdermozilla-central@1b713c9f40d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1524496
milestone67.0a1
backs out2fc5715105a265c701027c2a945e1bc1f3f26755
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
Backed out changeset 2fc5715105a2 due to bug 1524496. r=me
toolkit/xre/nsUpdateDriver.cpp
toolkit/xre/nsUpdateDriver.h
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -631,18 +631,23 @@ static void ApplyUpdate(nsIFile *greDir,
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
   // We use execv to spawn the updater process on all UNIX systems except Mac
   // OSX since it is known to cause problems on the Mac.  Windows has execv, but
   // it is a faked implementation that doesn't really replace the current
   // process. Instead it spawns a new process, so we gain nothing from using
   // execv on Windows.
   if (restart) {
     exit(execv(updaterPath.get(), argv));
-  } else {
-    *outpid = PR_CreateProcess(updaterPath.get(), argv, nullptr, nullptr);
+  }
+  *outpid = fork();
+  if (*outpid == -1) {
+    delete[] argv;
+    return;
+  } else if (*outpid == 0) {
+    exit(execv(updaterPath.get(), argv));
   }
   delete[] argv;
 #elif defined(XP_WIN)
   if (isStaged) {
     // Launch the updater to replace the installation with the staged updated.
     if (!WinLaunchChild(updaterPathW.get(), argc, argv)) {
       delete[] argv;
       return;
@@ -697,16 +702,35 @@ static bool ProcessHasTerminated(Process
   if (WaitForSingleObject(pt, 1000)) {
     return false;
   }
   CloseHandle(pt);
   return true;
 #elif defined(XP_MACOSX)
   // We're waiting for the process to terminate in LaunchChildMac.
   return true;
+#elif defined(XP_UNIX)
+  int exitStatus;
+  pid_t exited = waitpid(pt, &exitStatus, WNOHANG);
+  if (exited == 0) {
+    // Process is still running.
+    sleep(1);
+    return false;
+  }
+  if (exited == -1) {
+    LOG(("Error while checking if the updater process is finished"));
+    // This shouldn't happen, but if it does, the updater process is lost to us,
+    // so the best we can do is pretend that it's exited.
+    return true;
+  }
+  // If we get here, the process has exited; make sure it exited normally.
+  if (WIFEXITED(exitStatus) && (WEXITSTATUS(exitStatus) != 0)) {
+    LOG(("Error while running the updater process, check update.log"));
+  }
+  return true;
 #else
   // No way to have a non-blocking implementation on these platforms,
   // because we're using NSPR and it only provides a blocking wait.
   int32_t exitCode;
   PR_WaitProcess(pt, &exitCode);
   if (exitCode != 0) {
     LOG(("Error while running the updater process, check update.log"));
   }
--- a/toolkit/xre/nsUpdateDriver.h
+++ b/toolkit/xre/nsUpdateDriver.h
@@ -14,17 +14,17 @@
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 
 class nsIFile;
 
 #if defined(XP_WIN)
 #  include <windows.h>
 typedef HANDLE ProcessType;
-#elif defined(XP_MACOSX)
+#elif defined(XP_UNIX)
 typedef pid_t ProcessType;
 #else
 #  include "prproces.h"
 typedef PRProcess *ProcessType;
 #endif
 
 /**
  * This function processes any available updates.  As part of that process, it