From e80bea9a23243ddf8f58c0358df8118159800b53 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Tue, 6 Apr 2010 13:03:47 +0000 Subject: Make DidProcessCrash a bit more solid and accurate on Windows I hit the NOTREACHED() inside it while debugging an unrelated problem. Also, now there is one less special case in this function's contract. TEST=none BUG=38048 Review URL: http://codereview.chromium.org/1315009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43706 0039d316-1c4b-4281-b951-d872f2087c98 --- base/process_util_win.cc | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'base/process_util_win.cc') 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. -- cgit v1.1