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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // On POSIX there are no privileges to set. | 242 // On POSIX there are no privileges to set. |
243 return Open(pid); | 243 return Open(pid); |
244 } | 244 } |
245 | 245 |
246 // static | 246 // static |
247 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { | 247 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { |
248 DCHECK_NE(handle, GetCurrentProcessHandle()); | 248 DCHECK_NE(handle, GetCurrentProcessHandle()); |
249 return Process(handle); | 249 return Process(handle); |
250 } | 250 } |
251 | 251 |
252 #if !defined(OS_LINUX) | 252 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
253 // static | 253 // static |
254 bool Process::CanBackgroundProcesses() { | 254 bool Process::CanBackgroundProcesses() { |
255 return false; | 255 return false; |
256 } | 256 } |
257 #endif // !defined(OS_LINUX) | 257 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
258 | 258 |
259 bool Process::IsValid() const { | 259 bool Process::IsValid() const { |
260 return process_ != kNullProcessHandle; | 260 return process_ != kNullProcessHandle; |
261 } | 261 } |
262 | 262 |
263 ProcessHandle Process::Handle() const { | 263 ProcessHandle Process::Handle() const { |
264 return process_; | 264 return process_; |
265 } | 265 } |
266 | 266 |
267 Process Process::Duplicate() const { | 267 Process Process::Duplicate() const { |
(...skipping 29 matching lines...) Expand all Loading... |
297 } | 297 } |
298 | 298 |
299 bool Process::WaitForExit(int* exit_code) { | 299 bool Process::WaitForExit(int* exit_code) { |
300 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); | 300 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); |
301 } | 301 } |
302 | 302 |
303 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 303 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
304 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); | 304 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); |
305 } | 305 } |
306 | 306 |
307 #if !defined(OS_LINUX) | 307 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
308 bool Process::IsProcessBackgrounded() const { | 308 bool Process::IsProcessBackgrounded() const { |
309 // See SetProcessBackgrounded(). | 309 // See SetProcessBackgrounded(). |
310 DCHECK(IsValid()); | 310 DCHECK(IsValid()); |
311 return false; | 311 return false; |
312 } | 312 } |
313 | 313 |
314 bool Process::SetProcessBackgrounded(bool value) { | 314 bool Process::SetProcessBackgrounded(bool value) { |
315 // POSIX only allows lowering the priority of a process, so if we | 315 // Not implemented for POSIX systems other than Mac and Linux. With POSIX, if |
316 // were to lower it we wouldn't be able to raise it back to its initial | 316 // we were to lower the process priority we wouldn't be able to raise it back |
317 // priority. | 317 // to its initial priority. |
318 DCHECK(IsValid()); | 318 NOTIMPLEMENTED(); |
319 return false; | 319 return false; |
320 } | 320 } |
321 #endif // !defined(OS_LINUX) | 321 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
322 | 322 |
323 int Process::GetPriority() const { | 323 int Process::GetPriority() const { |
324 DCHECK(IsValid()); | 324 DCHECK(IsValid()); |
325 return getpriority(PRIO_PROCESS, process_); | 325 return getpriority(PRIO_PROCESS, process_); |
326 } | 326 } |
327 | 327 |
328 } // namespace base | 328 } // namespace base |
OLD | NEW |