Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: base/process_util_win.cc

Issue 18460: * Revert "POSIX: Get render_process_host to build." (Closed)
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process_util.h ('k') | chrome/browser/browser.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 bool LaunchApp(const CommandLine& cl, 146 bool LaunchApp(const CommandLine& cl,
147 bool wait, bool start_hidden, ProcessHandle* process_handle) { 147 bool wait, bool start_hidden, ProcessHandle* process_handle) {
148 return LaunchApp(cl.command_line_string(), wait, 148 return LaunchApp(cl.command_line_string(), wait,
149 start_hidden, process_handle); 149 start_hidden, process_handle);
150 } 150 }
151 151
152 // Attempts to kill the process identified by the given process 152 // Attempts to kill the process identified by the given process
153 // entry structure, giving it the specified exit code. 153 // entry structure, giving it the specified exit code.
154 // Returns true if this is successful, false otherwise. 154 // Returns true if this is successful, false otherwise.
155 bool KillProcess(int process_id, int exit_code, bool wait) { 155 bool KillProcess(int process_id, int exit_code, bool wait) {
156 bool result = false;
156 HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, 157 HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE,
157 FALSE, // Don't inherit handle 158 FALSE, // Don't inherit handle
158 process_id); 159 process_id);
159 if (process) 160 if (process) {
160 return KillProcess(process, exit_code, wait); 161 result = !!TerminateProcess(process, exit_code);
161 return false; 162 if (result && wait) {
162 } 163 // The process may not end immediately due to pending I/O
163 164 if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000))
164 bool KillProcess(HANDLE process, int exit_code, bool wait) { 165 DLOG(ERROR) << "Error waiting for process exit: " << GetLastError();
165 bool result = !!TerminateProcess(process, exit_code); 166 } else {
166 if (result && wait) { 167 DLOG(ERROR) << "Unable to terminate process: " << GetLastError();
167 // The process may not end immediately due to pending I/O 168 }
168 if (WAIT_OBJECT_0 != WaitForSingleObject(process, 60 * 1000)) 169 CloseHandle(process);
169 DLOG(ERROR) << "Error waiting for process exit: " << GetLastError();
170 } else {
171 DLOG(ERROR) << "Unable to terminate process: " << GetLastError();
172 } 170 }
173 CloseHandle(process);
174 return result; 171 return result;
175 } 172 }
176 173
177 bool DidProcessCrash(ProcessHandle handle) { 174 bool DidProcessCrash(ProcessHandle handle) {
178 DWORD exitcode = 0; 175 DWORD exitcode = 0;
179 if (!::GetExitCodeProcess(handle, &exitcode)) { 176 if (!::GetExitCodeProcess(handle, &exitcode)) {
180 NOTREACHED(); 177 NOTREACHED();
181 return false; 178 return false;
182 } 179 }
183 if (exitcode == STILL_ACTIVE) { 180 if (exitcode == STILL_ACTIVE) {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 void EnableTerminationOnHeapCorruption() { 623 void EnableTerminationOnHeapCorruption() {
627 // Ignore the result code. Supported on XP SP3 and Vista. 624 // Ignore the result code. Supported on XP SP3 and Vista.
628 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); 625 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
629 } 626 }
630 627
631 void RaiseProcessToHighPriority() { 628 void RaiseProcessToHighPriority() {
632 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 629 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
633 } 630 }
634 631
635 } // namespace base 632 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | chrome/browser/browser.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698