summaryrefslogtreecommitdiffstats
path: root/base/process_util_posix.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 20:57:58 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 20:57:58 +0000
commit076bf0b69eafa42accb20e5ccfe23805ed91655d (patch)
tree9db5d60018d0b35a87a87549ae82614e8b0f3e21 /base/process_util_posix.cc
parent07c00d99969c6584079c78a2e31cb0d5ad5beda7 (diff)
downloadchromium_src-076bf0b69eafa42accb20e5ccfe23805ed91655d.zip
chromium_src-076bf0b69eafa42accb20e5ccfe23805ed91655d.tar.gz
chromium_src-076bf0b69eafa42accb20e5ccfe23805ed91655d.tar.bz2
Make UITest::CrashAwareSleep portable.
Review URL: http://codereview.chromium.org/40119 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_posix.cc')
-rw-r--r--base/process_util_posix.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index e8845fb..453316d 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -182,7 +182,9 @@ bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
return false;
}
-bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) {
+namespace {
+
+int WaitpidWithTimeout(ProcessHandle handle, int wait_milliseconds) {
// This POSIX version of this function only guarantees that we wait no less
// than |wait_milliseconds| for the proces to exit. The child process may
// exit sometime before the timeout has ended but we may still block for
@@ -228,11 +230,25 @@ bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) {
ret_pid = waitpid(handle, &status, WNOHANG);
}
- if (status != -1) {
+ return status;
+}
+
+} // namespace
+
+bool WaitForSingleProcess(ProcessHandle handle, int wait_milliseconds) {
+ int status = WaitpidWithTimeout(handle, wait_milliseconds);
+ if (status != -1)
return WIFEXITED(status);
- } else {
+ else
+ return false;
+}
+
+bool CrashAwareSleep(ProcessHandle handle, int wait_milliseconds) {
+ int status = WaitpidWithTimeout(handle, wait_milliseconds);
+ if (status != -1)
+ return !(WIFEXITED(status) || WIFSIGNALED(status));
+ else
return false;
- }
}
namespace {