| Index: base/process_util_posix.cc
|
| diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
|
| index 07e31250021856273d7cf452bf7f728a66e77ac6..37ca0e4c8a719c1e266da82bf7ee78708931f660 100644
|
| --- a/base/process_util_posix.cc
|
| +++ b/base/process_util_posix.cc
|
| @@ -193,6 +193,8 @@ bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) {
|
| sleep_ms *= 2;
|
| }
|
|
|
| + // If we're waiting and the child hasn't died by now, force it
|
| + // with a SIGKILL.
|
| if (!exited)
|
| result = kill(process_id, SIGKILL) == 0;
|
| }
|
| @@ -586,40 +588,45 @@ void RaiseProcessToHighPriority() {
|
| // setpriority() or sched_getscheduler, but these all require extra rights.
|
| }
|
|
|
| -bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
|
| - int status;
|
| +TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) {
|
| + int status = 0;
|
| const pid_t result = HANDLE_EINTR(waitpid(handle, &status, WNOHANG));
|
| if (result == -1) {
|
| PLOG(ERROR) << "waitpid(" << handle << ")";
|
| - if (child_exited)
|
| - *child_exited = false;
|
| - return false;
|
| + if (exit_code)
|
| + *exit_code = 0;
|
| + return TERMINATION_STATUS_NORMAL_TERMINATION;
|
| } else if (result == 0) {
|
| // the child hasn't exited yet.
|
| - if (child_exited)
|
| - *child_exited = false;
|
| - return false;
|
| + if (exit_code)
|
| + *exit_code = 0;
|
| + return TERMINATION_STATUS_STILL_RUNNING;
|
| }
|
|
|
| - if (child_exited)
|
| - *child_exited = true;
|
| + if (exit_code)
|
| + *exit_code = status;
|
|
|
| if (WIFSIGNALED(status)) {
|
| switch (WTERMSIG(status)) {
|
| - case SIGSEGV:
|
| - case SIGILL:
|
| case SIGABRT:
|
| + case SIGBUS:
|
| case SIGFPE:
|
| - return true;
|
| + case SIGILL:
|
| + case SIGSEGV:
|
| + return TERMINATION_STATUS_PROCESS_CRASHED;
|
| + case SIGINT:
|
| + case SIGKILL:
|
| + case SIGTERM:
|
| + return TERMINATION_STATUS_PROCESS_WAS_KILLED;
|
| default:
|
| - return false;
|
| + break;
|
| }
|
| }
|
|
|
| - if (WIFEXITED(status))
|
| - return WEXITSTATUS(status) != 0;
|
| + if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
|
| + return TERMINATION_STATUS_ABNORMAL_TERMINATION;
|
|
|
| - return false;
|
| + return TERMINATION_STATUS_NORMAL_TERMINATION;
|
| }
|
|
|
| bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
|
|
|