From b987656f1f7234267684df3b67e08896db9d3aac Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 29 Mar 2015 20:32:23 +0800 Subject: [PATCH] It is not safe to get exit code once the child is reaped Continues #1311. --- atom/common/platform_util_linux.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/atom/common/platform_util_linux.cc b/atom/common/platform_util_linux.cc index d1173c6f..f70d16a5 100644 --- a/atom/common/platform_util_linux.cc +++ b/atom/common/platform_util_linux.cc @@ -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) { -- 2.43.0