| OLD | NEW |
| 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 <sys/resource.h> | 7 #include <sys/resource.h> |
| 8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
| 9 | 9 |
| 10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 return process_ == GetCurrentProcessHandle(); | 280 return process_ == GetCurrentProcessHandle(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void Process::Close() { | 283 void Process::Close() { |
| 284 process_ = kNullProcessHandle; | 284 process_ = kNullProcessHandle; |
| 285 // if the process wasn't terminated (so we waited) or the state | 285 // if the process wasn't terminated (so we waited) or the state |
| 286 // wasn't already collected w/ a wait from process_utils, we're gonna | 286 // wasn't already collected w/ a wait from process_utils, we're gonna |
| 287 // end up w/ a zombie when it does finally exit. | 287 // end up w/ a zombie when it does finally exit. |
| 288 } | 288 } |
| 289 | 289 |
| 290 void Process::Terminate(int result_code) { | 290 bool Process::Terminate(int result_code, bool wait) const { |
| 291 // result_code isn't supportable. | 291 // result_code isn't supportable. |
| 292 DCHECK(IsValid()); | 292 DCHECK(IsValid()); |
| 293 // We don't wait here. It's the responsibility of other code to reap the | 293 // We don't wait here. It's the responsibility of other code to reap the |
| 294 // child. | 294 // child. |
| 295 KillProcess(process_, result_code, false); | 295 // TODO(rvargas) crbug/417532: Move the implementation here. |
| 296 return KillProcess(process_, result_code, wait); |
| 296 } | 297 } |
| 297 | 298 |
| 298 bool Process::WaitForExit(int* exit_code) { | 299 bool Process::WaitForExit(int* exit_code) { |
| 299 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); | 300 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); |
| 300 } | 301 } |
| 301 | 302 |
| 302 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 303 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 303 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); | 304 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); |
| 304 } | 305 } |
| 305 | 306 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 318 return false; | 319 return false; |
| 319 } | 320 } |
| 320 #endif // !defined(OS_LINUX) | 321 #endif // !defined(OS_LINUX) |
| 321 | 322 |
| 322 int Process::GetPriority() const { | 323 int Process::GetPriority() const { |
| 323 DCHECK(IsValid()); | 324 DCHECK(IsValid()); |
| 324 return getpriority(PRIO_PROCESS, process_); | 325 return getpriority(PRIO_PROCESS, process_); |
| 325 } | 326 } |
| 326 | 327 |
| 327 } // namspace base | 328 } // namspace base |
| OLD | NEW |