diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:31:28 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 23:31:28 +0000 |
commit | d2442374dd7607a8d140f4e29fd3b80a3309c615 (patch) | |
tree | 5bd500b29c2c2e7253ff0f4efd47fe90e6ebe9b6 /base/process_util_posix.cc | |
parent | 367d707fa4f9a6712ccb7035c530da5788a4f5a2 (diff) | |
download | chromium_src-d2442374dd7607a8d140f4e29fd3b80a3309c615.zip chromium_src-d2442374dd7607a8d140f4e29fd3b80a3309c615.tar.gz chromium_src-d2442374dd7607a8d140f4e29fd3b80a3309c615.tar.bz2 |
Fix KillProcess so it doesn't report everything as a failure.
BUG=none
TEST=UI tests on Mac should no longer all log that kills are failing.
Review URL: http://codereview.chromium.org/155297
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_posix.cc')
-rw-r--r-- | base/process_util_posix.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index c6c1783..eb3b814 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -75,19 +75,26 @@ bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) { if (result && wait) { int tries = 60; // The process may not end immediately due to pending I/O + bool exited = false; while (tries-- > 0) { int pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG)); - if (pid == process_id) + if (pid == process_id) { + exited = true; break; + } sleep(1); } - result = kill(process_id, SIGKILL) == 0; + if (!exited) { + result = kill(process_id, SIGKILL) == 0; + } } - if (!result) - DLOG(ERROR) << "Unable to terminate process."; + if (!result) { + DLOG(ERROR) << "Unable to terminate process " << process_id << "; error " + << errno; + } return result; } |