diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 07:41:22 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 07:41:22 +0000 |
commit | 8004e68a8f23602f928eb4f0180f041b97d7ea0a (patch) | |
tree | 62fb0d4e19bd39aefd60e6cbd9fe51568c21d202 /base/process_util_win.cc | |
parent | 30248507aa0aac429bdd2b9f68dae9a2a5f08848 (diff) | |
download | chromium_src-8004e68a8f23602f928eb4f0180f041b97d7ea0a.zip chromium_src-8004e68a8f23602f928eb4f0180f041b97d7ea0a.tar.gz chromium_src-8004e68a8f23602f928eb4f0180f041b97d7ea0a.tar.bz2 |
[GTTF] Add an always-working timeout for browser_tests.
This one is implemented in the out-of-process launcher, so it's guaranteed
to work.
Not removing the MessageLoop delayed task sent inside the test because
currently not all browser tests use the launcher (sync tests?).
TEST=browser_tests
BUG=38053
Review URL: http://codereview.chromium.org/949002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41694 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_win.cc')
-rw-r--r-- | base/process_util_win.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc index 8f08c1c..05d3d60 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -348,14 +348,24 @@ bool DidProcessCrash(bool* child_exited, ProcessHandle handle) { } bool WaitForExitCode(ProcessHandle handle, int* exit_code) { - ScopedHandle closer(handle); // Ensure that we always close the handle. - if (::WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0) { - NOTREACHED(); + bool success = WaitForExitCodeWithTimeout(handle, exit_code, INFINITE); + if (!success) + CloseProcessHandle(handle); + return success; +} + +bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, + int64 timeout_milliseconds) { + if (::WaitForSingleObject(handle, timeout_milliseconds) != WAIT_OBJECT_0) return false; - } DWORD temp_code; // Don't clobber out-parameters in case of failure. if (!::GetExitCodeProcess(handle, &temp_code)) return false; + + // Only close the handle on success, to give the caller a chance to forcefully + // terminate the process if he wants to. + CloseProcessHandle(handle); + *exit_code = temp_code; return true; } |