| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/process_util.h" | 5 #include "base/process_util.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <winternl.h> | 8 #include <winternl.h> |
| 9 #include <psapi.h> | 9 #include <psapi.h> |
| 10 | 10 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (result && wait) { | 263 if (result && wait) { |
| 264 // The process may not end immediately due to pending I/O | 264 // The process may not end immediately due to pending I/O |
| 265 if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000)) | 265 if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000)) |
| 266 DLOG(ERROR) << "Error waiting for process exit: " << GetLastError(); | 266 DLOG(ERROR) << "Error waiting for process exit: " << GetLastError(); |
| 267 } else if (!result) { | 267 } else if (!result) { |
| 268 DLOG(ERROR) << "Unable to terminate process: " << GetLastError(); | 268 DLOG(ERROR) << "Unable to terminate process: " << GetLastError(); |
| 269 } | 269 } |
| 270 return result; | 270 return result; |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool DidProcessCrash(ProcessHandle handle) { | 273 bool DidProcessCrash(bool* child_exited, ProcessHandle handle) { |
| 274 DWORD exitcode = 0; | 274 DWORD exitcode = 0; |
| 275 |
| 276 if (child_exited) |
| 277 *child_exited = true; // On Windows it an error to call this function if |
| 278 // the child hasn't already exited. |
| 275 if (!::GetExitCodeProcess(handle, &exitcode)) { | 279 if (!::GetExitCodeProcess(handle, &exitcode)) { |
| 276 NOTREACHED(); | 280 NOTREACHED(); |
| 277 return false; | 281 return false; |
| 278 } | 282 } |
| 279 if (exitcode == STILL_ACTIVE) { | 283 if (exitcode == STILL_ACTIVE) { |
| 280 // The process is likely not dead or it used 0x103 as exit code. | 284 // The process is likely not dead or it used 0x103 as exit code. |
| 281 NOTREACHED(); | 285 NOTREACHED(); |
| 282 return false; | 286 return false; |
| 283 } | 287 } |
| 284 | 288 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 void EnableTerminationOnHeapCorruption() { | 732 void EnableTerminationOnHeapCorruption() { |
| 729 // Ignore the result code. Supported on XP SP3 and Vista. | 733 // Ignore the result code. Supported on XP SP3 and Vista. |
| 730 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); | 734 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); |
| 731 } | 735 } |
| 732 | 736 |
| 733 void RaiseProcessToHighPriority() { | 737 void RaiseProcessToHighPriority() { |
| 734 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 738 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
| 735 } | 739 } |
| 736 | 740 |
| 737 } // namespace base | 741 } // namespace base |
| OLD | NEW |