It is not safe to get exit code once the child is reaped

Continues #1311.
This commit is contained in:
Cheng Zhao 2015-03-29 20:32:23 +08:00
parent e0d0e7651f
commit b987656f1f

View 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". // bring up a new terminal if necessary. See "man mailcap".
options.environ["MM_NOTTTY"] = "1"; options.environ["MM_NOTTTY"] = "1";
base::ProcessHandle handle; base::Process process = base::LaunchProcess(argv, options);
if (base::LaunchProcess(argv, options, &handle)) { if (!process.IsValid())
int exit_code; return false;
base::Process process(handle);
base::EnsureProcessGetsReaped(handle);
process.WaitForExit(&exit_code);
return (exit_code == 0);
}
return false; int exit_code = -1;
if (!process.WaitForExit(&exit_code))
return false;
return (exit_code == 0);
} }
void XDGOpen(const std::string& path) { void XDGOpen(const std::string& path) {