OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 void Process::Close() { | 289 void Process::Close() { |
290 process_ = kNullProcessHandle; | 290 process_ = kNullProcessHandle; |
291 // if the process wasn't terminated (so we waited) or the state | 291 // if the process wasn't terminated (so we waited) or the state |
292 // wasn't already collected w/ a wait from process_utils, we're gonna | 292 // wasn't already collected w/ a wait from process_utils, we're gonna |
293 // end up w/ a zombie when it does finally exit. | 293 // end up w/ a zombie when it does finally exit. |
294 } | 294 } |
295 | 295 |
296 #if !defined(OS_NACL_NONSFI) | 296 #if !defined(OS_NACL_NONSFI) |
297 bool Process::Terminate(int exit_code, bool wait) const { | 297 bool Process::Terminate(int exit_code, bool wait) const { |
298 // result_code isn't supportable. | 298 // exit_code isn't supportable. |
299 DCHECK(IsValid()); | 299 DCHECK(IsValid()); |
300 DCHECK_GT(process_, 1); | 300 CHECK_GT(process_, 0); |
| 301 |
301 bool result = kill(process_, SIGTERM) == 0; | 302 bool result = kill(process_, SIGTERM) == 0; |
302 if (result && wait) { | 303 if (result && wait) { |
303 int tries = 60; | 304 int tries = 60; |
304 | 305 |
305 if (RunningOnValgrind()) { | 306 if (RunningOnValgrind()) { |
306 // Wait for some extra time when running under Valgrind since the child | 307 // Wait for some extra time when running under Valgrind since the child |
307 // processes may take some time doing leak checking. | 308 // processes may take some time doing leak checking. |
308 tries *= 2; | 309 tries *= 2; |
309 } | 310 } |
310 | 311 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return false; | 371 return false; |
371 } | 372 } |
372 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) | 373 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
373 | 374 |
374 int Process::GetPriority() const { | 375 int Process::GetPriority() const { |
375 DCHECK(IsValid()); | 376 DCHECK(IsValid()); |
376 return getpriority(PRIO_PROCESS, process_); | 377 return getpriority(PRIO_PROCESS, process_); |
377 } | 378 } |
378 | 379 |
379 } // namespace base | 380 } // namespace base |
OLD | NEW |