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

Side by Side Diff: base/process/process_win.cc

Issue 982973003: Align base::Process::Terminate with base::KillProcess for Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/process.h" 5 #include "base/process/process.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 void Process::Close() { 118 void Process::Close() {
119 is_current_process_ = false; 119 is_current_process_ = false;
120 if (!process_.IsValid()) 120 if (!process_.IsValid())
121 return; 121 return;
122 122
123 process_.Close(); 123 process_.Close();
124 } 124 }
125 125
126 void Process::Terminate(int result_code) { 126 void Process::Terminate(int result_code) {
127 DCHECK(IsValid()); 127 ::TerminateProcess(Handle(), result_code);
128
129 // Call NtTerminateProcess directly, without going through the import table,
130 // which might have been hooked with a buggy replacement by third party
131 // software. http://crbug.com/81449.
cpu_(ooo_6.6-7.5) 2015/03/06 13:14:40 add this bug to the CL? according to #35 there it
rvargas (doing something else) 2015/03/06 18:51:59 Added to the description. We should not be doing
132 HMODULE module = GetModuleHandle(L"ntdll.dll");
133 typedef UINT (WINAPI *TerminateProcessPtr)(HANDLE handle, UINT code);
134 TerminateProcessPtr terminate_process = reinterpret_cast<TerminateProcessPtr>(
135 GetProcAddress(module, "NtTerminateProcess"));
136 terminate_process(Handle(), result_code);
137 } 128 }
138 129
139 bool Process::WaitForExit(int* exit_code) { 130 bool Process::WaitForExit(int* exit_code) {
140 return WaitForExitWithTimeout(TimeDelta::FromMilliseconds(INFINITE), 131 return WaitForExitWithTimeout(TimeDelta::FromMilliseconds(INFINITE),
141 exit_code); 132 exit_code);
142 } 133 }
143 134
144 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { 135 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) {
145 // Limit timeout to INFINITE. 136 // Limit timeout to INFINITE.
146 DWORD timeout_ms = saturated_cast<DWORD>(timeout.InMilliseconds()); 137 DWORD timeout_ms = saturated_cast<DWORD>(timeout.InMilliseconds());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 184
194 return (::SetPriorityClass(Handle(), priority) != 0); 185 return (::SetPriorityClass(Handle(), priority) != 0);
195 } 186 }
196 187
197 int Process::GetPriority() const { 188 int Process::GetPriority() const {
198 DCHECK(IsValid()); 189 DCHECK(IsValid());
199 return ::GetPriorityClass(Handle()); 190 return ::GetPriorityClass(Handle());
200 } 191 }
201 192
202 } // namespace base 193 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698