summaryrefslogtreecommitdiffstats
path: root/base/process_util_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/process_util_win.cc')
-rw-r--r--base/process_util_win.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 05d3d60..a845ac7 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.