diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util.h | 10 | ||||
-rw-r--r-- | base/process_util_posix.cc | 17 | ||||
-rw-r--r-- | base/process_util_win.cc | 6 |
3 files changed, 7 insertions, 26 deletions
diff --git a/base/process_util.h b/base/process_util.h index a692870..9eb8690 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -172,13 +172,9 @@ bool KillProcessById(ProcessId process_id, int exit_code, bool wait); #endif // Get the termination status (exit code) of the process and return true if the -// status indicates the process crashed. |child_exited| is set to true iff the -// child process has terminated. (|child_exited| may be NULL.) -// -// On Windows, it is an error to call this if the process hasn't terminated -// yet. On POSIX, |child_exited| is set correctly since we detect terminate in -// a different manner on POSIX. -bool DidProcessCrash(bool* child_exited, ProcessHandle handle); +// status indicates the process crashed. It is an error to call this if the +// process hasn't terminated yet. +bool DidProcessCrash(ProcessHandle handle); // Waits for process to exit. In POSIX systems, if the process hasn't been // signaled then puts the exit code in |exit_code|; otherwise it's considered diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 87abbb8..562b8e9 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -140,24 +140,13 @@ void RaiseProcessToHighPriority() { // setpriority() or sched_getscheduler, but these all require extra rights. } -bool DidProcessCrash(bool* child_exited, ProcessHandle handle) { +bool DidProcessCrash(ProcessHandle handle) { int status; - const int result = waitpid(handle, &status, WNOHANG); - if (result == -1) { - LOG(ERROR) << "waitpid failed with errno:" << errno; - if (child_exited) - *child_exited = false; - return false; - } else if (result == 0) { - // the child hasn't exited yet. - if (child_exited) - *child_exited = false; + if (waitpid(handle, &status, WNOHANG)) { + // I feel like dancing! return false; } - if (child_exited) - *child_exited = true; - if (WIFSIGNALED(status)) { switch(WTERMSIG(status)) { case SIGSEGV: diff --git a/base/process_util_win.cc b/base/process_util_win.cc index fc05664..13fec9a 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -270,12 +270,8 @@ bool KillProcess(ProcessHandle process, int exit_code, bool wait) { return result; } -bool DidProcessCrash(bool* child_exited, ProcessHandle handle) { +bool DidProcessCrash(ProcessHandle handle) { DWORD exitcode = 0; - - if (child_exited) - *child_exited = true; // On Windows it an error to call this function if - // the child hasn't already exited. if (!::GetExitCodeProcess(handle, &exitcode)) { NOTREACHED(); return false; |