summaryrefslogtreecommitdiffstats
path: root/base/process_util_win.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-06 13:03:47 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-06 13:03:47 +0000
commite80bea9a23243ddf8f58c0358df8118159800b53 (patch)
tree43f7da3680f9b6045df619184d629e7347ca3c75 /base/process_util_win.cc
parent9bf97140e3fb566cda9436a5f2ba33df01f21d6d (diff)
downloadchromium_src-e80bea9a23243ddf8f58c0358df8118159800b53.zip
chromium_src-e80bea9a23243ddf8f58c0358df8118159800b53.tar.gz
chromium_src-e80bea9a23243ddf8f58c0358df8118159800b53.tar.bz2
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
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.