OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 CloseHandle(process); | 171 CloseHandle(process); |
172 return ret; | 172 return ret; |
173 } | 173 } |
174 | 174 |
175 bool KillProcess(ProcessHandle process, int exit_code, bool wait) { | 175 bool KillProcess(ProcessHandle process, int exit_code, bool wait) { |
176 bool result = (TerminateProcess(process, exit_code) != FALSE); | 176 bool result = (TerminateProcess(process, exit_code) != FALSE); |
177 if (result && wait) { | 177 if (result && wait) { |
178 // The process may not end immediately due to pending I/O | 178 // The process may not end immediately due to pending I/O |
179 if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000)) | 179 if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000)) |
180 DLOG(ERROR) << "Error waiting for process exit: " << GetLastError(); | 180 DLOG(ERROR) << "Error waiting for process exit: " << GetLastError(); |
181 } else { | 181 } else if (!result) { |
182 DLOG(ERROR) << "Unable to terminate process: " << GetLastError(); | 182 DLOG(ERROR) << "Unable to terminate process: " << GetLastError(); |
183 } | 183 } |
184 return result; | 184 return result; |
185 } | 185 } |
186 | 186 |
187 bool DidProcessCrash(ProcessHandle handle) { | 187 bool DidProcessCrash(ProcessHandle handle) { |
188 DWORD exitcode = 0; | 188 DWORD exitcode = 0; |
189 if (!::GetExitCodeProcess(handle, &exitcode)) { | 189 if (!::GetExitCodeProcess(handle, &exitcode)) { |
190 NOTREACHED(); | 190 NOTREACHED(); |
191 return false; | 191 return false; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 void EnableTerminationOnHeapCorruption() { | 642 void EnableTerminationOnHeapCorruption() { |
643 // Ignore the result code. Supported on XP SP3 and Vista. | 643 // Ignore the result code. Supported on XP SP3 and Vista. |
644 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); | 644 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); |
645 } | 645 } |
646 | 646 |
647 void RaiseProcessToHighPriority() { | 647 void RaiseProcessToHighPriority() { |
648 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 648 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
649 } | 649 } |
650 | 650 |
651 } // namespace base | 651 } // namespace base |
OLD | NEW |