]> khamidou — GitHub mirrors - electron.git/commitdiff
It is not safe to get exit code once the child is reaped
authorCheng Zhao <zcbenz@gmail.com>
Sun, 29 Mar 2015 12:32:23 +0000 (20:32 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 29 Mar 2015 12:32:23 +0000 (20:32 +0800)
Continues #1311.

atom/common/platform_util_linux.cc

index d1173c6f4c9b2e43e9b94bab5819db129ee82404..f70d16a559a7a387fb63e79bd95d0e00280ca6e4 100644 (file)
@@ -26,16 +26,15 @@ bool XDGUtil(const std::string& util, const std::string& arg) {
   // bring up a new terminal if necessary.  See "man mailcap".
   options.environ["MM_NOTTTY"] = "1";
 
-  base::ProcessHandle handle;
-  if (base::LaunchProcess(argv, options, &handle)) {
-      int exit_code;
-      base::Process process(handle);
-      base::EnsureProcessGetsReaped(handle);
-      process.WaitForExit(&exit_code);
-      return (exit_code == 0);
-  }
-
-  return false;
+  base::Process process = base::LaunchProcess(argv, options);
+  if (!process.IsValid())
+    return false;
+
+  int exit_code = -1;
+  if (!process.WaitForExit(&exit_code))
+    return false;
+
+  return (exit_code == 0);
 }
 
 void XDGOpen(const std::string& path) {