| 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/time.h> | 8 #include <sys/time.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 void Process::Terminate(int result_code) { | 84 void Process::Terminate(int result_code) { |
| 85 // result_code isn't supportable. | 85 // result_code isn't supportable. |
| 86 DCHECK(IsValid()); | 86 DCHECK(IsValid()); |
| 87 // We don't wait here. It's the responsibility of other code to reap the | 87 // We don't wait here. It's the responsibility of other code to reap the |
| 88 // child. | 88 // child. |
| 89 KillProcess(process_, result_code, false); | 89 KillProcess(process_, result_code, false); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool Process::WaitForExit(int* exit_code) { |
| 93 // TODO(rvargas) crbug.com/417532: Remove this constant. |
| 94 const int kNoTimeout = -1; |
| 95 return WaitForExitWithTimeout(TimeDelta::FromMilliseconds(kNoTimeout), |
| 96 exit_code); |
| 97 } |
| 98 |
| 99 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 100 // TODO(rvargas) crbug.com/417532: Move the implementation here. |
| 101 return base::WaitForExitCodeWithTimeout(Handle(), exit_code, timeout); |
| 102 } |
| 103 |
| 92 #if !defined(OS_LINUX) | 104 #if !defined(OS_LINUX) |
| 93 bool Process::IsProcessBackgrounded() const { | 105 bool Process::IsProcessBackgrounded() const { |
| 94 // See SetProcessBackgrounded(). | 106 // See SetProcessBackgrounded(). |
| 95 DCHECK(IsValid()); | 107 DCHECK(IsValid()); |
| 96 return false; | 108 return false; |
| 97 } | 109 } |
| 98 | 110 |
| 99 bool Process::SetProcessBackgrounded(bool value) { | 111 bool Process::SetProcessBackgrounded(bool value) { |
| 100 // POSIX only allows lowering the priority of a process, so if we | 112 // POSIX only allows lowering the priority of a process, so if we |
| 101 // were to lower it we wouldn't be able to raise it back to its initial | 113 // were to lower it we wouldn't be able to raise it back to its initial |
| 102 // priority. | 114 // priority. |
| 103 DCHECK(IsValid()); | 115 DCHECK(IsValid()); |
| 104 return false; | 116 return false; |
| 105 } | 117 } |
| 106 #endif // !defined(OS_LINUX) | 118 #endif // !defined(OS_LINUX) |
| 107 | 119 |
| 108 int Process::GetPriority() const { | 120 int Process::GetPriority() const { |
| 109 DCHECK(IsValid()); | 121 DCHECK(IsValid()); |
| 110 return getpriority(PRIO_PROCESS, process_); | 122 return getpriority(PRIO_PROCESS, process_); |
| 111 } | 123 } |
| 112 | 124 |
| 113 } // namspace base | 125 } // namspace base |
| OLD | NEW |