Index: base/process/process_win.cc |
diff --git a/base/process/process_win.cc b/base/process/process_win.cc |
index d72dd49c9d69196861d0e0e89929b339cdf5c0c0..0d312a3599088eabf4bc2043a5f875b6d1f9d019 100644 |
--- a/base/process/process_win.cc |
+++ b/base/process/process_win.cc |
@@ -32,6 +32,9 @@ Process::Process(RValue other) |
other.object->Close(); |
} |
+Process::~Process() { |
+} |
+ |
Process& Process::operator=(RValue other) { |
if (this != other.object) { |
process_.Set(other.object->process_.Take()); |
@@ -123,10 +126,17 @@ void Process::Close() { |
process_.Close(); |
} |
-bool Process::Terminate(int result_code, bool wait) const { |
+bool Process::Terminate(int exit_code, bool wait) const { |
DCHECK(IsValid()); |
- // TODO(rvargas) crbug/417532: Move the implementation here. |
- return KillProcess(Handle(), result_code, wait); |
+ bool result = (::TerminateProcess(Handle(), exit_code) != FALSE); |
+ if (result && wait) { |
+ // The process may not end immediately due to pending I/O |
+ if (::WaitForSingleObject(Handle(), 60 * 1000) != WAIT_OBJECT_0) |
+ DPLOG(ERROR) << "Error waiting for process exit"; |
+ } else if (!result) { |
+ DPLOG(ERROR) << "Unable to terminate process"; |
+ } |
+ return result; |
} |
bool Process::WaitForExit(int* exit_code) { |