diff options
Diffstat (limited to 'base/process_util_posix.cc')
-rw-r--r-- | base/process_util_posix.cc | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index 26301d2..6c7a9f6 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -724,15 +724,14 @@ bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, return false; if (!waitpid_success) return false; + if (!WIFEXITED(status)) + return false; if (WIFSIGNALED(status)) { *exit_code = -1; return true; } - if (WIFEXITED(status)) { - *exit_code = WEXITSTATUS(status); - return true; - } - return false; + *exit_code = WEXITSTATUS(status); + return true; } #if defined(OS_MACOSX) @@ -822,6 +821,19 @@ bool WaitForSingleProcess(ProcessHandle handle, int64 wait_milliseconds) { } } +bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds) { + bool waitpid_success; + int status = WaitpidWithTimeout(handle, wait_milliseconds, &waitpid_success); + if (status != -1) { + DCHECK(waitpid_success); + return !(WIFEXITED(status) || WIFSIGNALED(status)); + } else { + // If waitpid returned with an error, then the process doesn't exist + // (which most probably means it didn't exist before our call). + return waitpid_success; + } +} + int64 TimeValToMicroseconds(const struct timeval& tv) { static const int kMicrosecondsPerSecond = 1000000; int64 ret = tv.tv_sec; // Avoid (int * int) integer overflow. |