Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2706)

Unified Diff: base/process_util_posix.cc

Issue 40119: Make UITest::CrashAwareSleep portable. (Closed)
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_posix.cc
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index e8845fb9ca625d6504a50d6cfe32e42ae566cd43..453316d910c27ff30c96ac2f09a859259b689aa6 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 {
« no previous file with comments | « base/process_util.h ('k') | base/process_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698