| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
| 10 #include <sys/wait.h> | 10 #include <sys/wait.h> |
| 11 | 11 |
| 12 #include "base/debug/activity_tracker.h" | |
| 13 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
| 14 #include "base/logging.h" | 13 #include "base/logging.h" |
| 15 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
| 16 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
| 17 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 16 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 19 | 18 |
| 20 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
| 21 #include <sys/event.h> | 20 #include <sys/event.h> |
| 22 #endif | 21 #endif |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 347 |
| 349 return result; | 348 return result; |
| 350 } | 349 } |
| 351 #endif // !defined(OS_NACL_NONSFI) | 350 #endif // !defined(OS_NACL_NONSFI) |
| 352 | 351 |
| 353 bool Process::WaitForExit(int* exit_code) { | 352 bool Process::WaitForExit(int* exit_code) { |
| 354 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); | 353 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); |
| 355 } | 354 } |
| 356 | 355 |
| 357 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 356 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 358 // Record the event that this thread is blocking upon (for hang diagnosis). | |
| 359 base::debug::ScopedProcessWaitActivity process_activity(this); | |
| 360 | |
| 361 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); | 357 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); |
| 362 } | 358 } |
| 363 | 359 |
| 364 #if !defined(OS_LINUX) | 360 #if !defined(OS_LINUX) |
| 365 bool Process::IsProcessBackgrounded() const { | 361 bool Process::IsProcessBackgrounded() const { |
| 366 // See SetProcessBackgrounded(). | 362 // See SetProcessBackgrounded(). |
| 367 DCHECK(IsValid()); | 363 DCHECK(IsValid()); |
| 368 return false; | 364 return false; |
| 369 } | 365 } |
| 370 | 366 |
| 371 bool Process::SetProcessBackgrounded(bool value) { | 367 bool Process::SetProcessBackgrounded(bool value) { |
| 372 // Not implemented for POSIX systems other than Linux. With POSIX, if we were | 368 // Not implemented for POSIX systems other than Linux. With POSIX, if we were |
| 373 // to lower the process priority we wouldn't be able to raise it back to its | 369 // to lower the process priority we wouldn't be able to raise it back to its |
| 374 // initial priority. | 370 // initial priority. |
| 375 NOTIMPLEMENTED(); | 371 NOTIMPLEMENTED(); |
| 376 return false; | 372 return false; |
| 377 } | 373 } |
| 378 #endif // !defined(OS_LINUX) | 374 #endif // !defined(OS_LINUX) |
| 379 | 375 |
| 380 int Process::GetPriority() const { | 376 int Process::GetPriority() const { |
| 381 DCHECK(IsValid()); | 377 DCHECK(IsValid()); |
| 382 return getpriority(PRIO_PROCESS, process_); | 378 return getpriority(PRIO_PROCESS, process_); |
| 383 } | 379 } |
| 384 | 380 |
| 385 } // namespace base | 381 } // namespace base |
| OLD | NEW |