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. |