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

Unified Diff: base/process_util_win.cc

Issue 1315009: Make DidProcessCrash a bit more solid and accurate on Windows (Closed)
Patch Set: now with a test Created 10 years, 9 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_unittest.cc ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_win.cc
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 05d3d60cb79437feb9f84ba2637730d7901a11dc..a845ac79a3beba282d42a36d277ede9545fae0f6 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -318,19 +318,33 @@ bool KillProcess(ProcessHandle process, int exit_code, bool wait) {
bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
DWORD exitcode = 0;
- if (child_exited)
- *child_exited = true; // On Windows it an error to call this function if
- // the child hasn't already exited.
if (!::GetExitCodeProcess(handle, &exitcode)) {
NOTREACHED();
+ // Assume the child has exited.
+ if (child_exited)
+ *child_exited = true;
return false;
}
if (exitcode == STILL_ACTIVE) {
- // The process is likely not dead or it used 0x103 as exit code.
+ DWORD wait_result = WaitForSingleObject(handle, 0);
+ if (wait_result == WAIT_TIMEOUT) {
+ if (child_exited)
+ *child_exited = false;
+ return false;
+ }
+
+ DCHECK_EQ(WAIT_OBJECT_0, wait_result);
+
+ // Strange, the process used 0x103 (STILL_ACTIVE) as exit code.
NOTREACHED();
+
return false;
}
+ // We're sure the child has exited.
+ if (child_exited)
+ *child_exited = true;
+
// Warning, this is not generic code; it heavily depends on the way
// the rest of the code kills a process.
« no previous file with comments | « base/process_util_unittest.cc ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698