| OLD | NEW |
| 1 // Copyright 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // On POSIX there are no privileges to set. | 246 // On POSIX there are no privileges to set. |
| 247 return Open(pid); | 247 return Open(pid); |
| 248 } | 248 } |
| 249 | 249 |
| 250 // static | 250 // static |
| 251 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { | 251 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { |
| 252 DCHECK_NE(handle, GetCurrentProcessHandle()); | 252 DCHECK_NE(handle, GetCurrentProcessHandle()); |
| 253 return Process(handle); | 253 return Process(handle); |
| 254 } | 254 } |
| 255 | 255 |
| 256 #if !defined(OS_LINUX) && !defined(OS_MACOSX) | 256 #if !defined(OS_LINUX) |
| 257 // static | 257 // static |
| 258 bool Process::CanBackgroundProcesses() { | 258 bool Process::CanBackgroundProcesses() { |
| 259 return false; | 259 return false; |
| 260 } | 260 } |
| 261 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) | 261 #endif // !defined(OS_LINUX) |
| 262 | 262 |
| 263 bool Process::IsValid() const { | 263 bool Process::IsValid() const { |
| 264 return process_ != kNullProcessHandle; | 264 return process_ != kNullProcessHandle; |
| 265 } | 265 } |
| 266 | 266 |
| 267 ProcessHandle Process::Handle() const { | 267 ProcessHandle Process::Handle() const { |
| 268 return process_; | 268 return process_; |
| 269 } | 269 } |
| 270 | 270 |
| 271 Process Process::Duplicate() const { | 271 Process Process::Duplicate() const { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 #endif // !defined(OS_NACL_NONSFI) | 346 #endif // !defined(OS_NACL_NONSFI) |
| 347 | 347 |
| 348 bool Process::WaitForExit(int* exit_code) { | 348 bool Process::WaitForExit(int* exit_code) { |
| 349 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); | 349 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); |
| 350 } | 350 } |
| 351 | 351 |
| 352 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 352 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 353 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); | 353 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); |
| 354 } | 354 } |
| 355 | 355 |
| 356 #if !defined(OS_LINUX) && !defined(OS_MACOSX) | 356 #if !defined(OS_LINUX) |
| 357 bool Process::IsProcessBackgrounded() const { | 357 bool Process::IsProcessBackgrounded() const { |
| 358 // See SetProcessBackgrounded(). | 358 // See SetProcessBackgrounded(). |
| 359 DCHECK(IsValid()); | 359 DCHECK(IsValid()); |
| 360 return false; | 360 return false; |
| 361 } | 361 } |
| 362 | 362 |
| 363 bool Process::SetProcessBackgrounded(bool value) { | 363 bool Process::SetProcessBackgrounded(bool value) { |
| 364 // Not implemented for POSIX systems other than Mac and Linux. With POSIX, if | 364 // POSIX only allows lowering the priority of a process, so if we |
| 365 // we were to lower the process priority we wouldn't be able to raise it back | 365 // were to lower it we wouldn't be able to raise it back to its initial |
| 366 // to its initial priority. | 366 // priority. |
| 367 NOTIMPLEMENTED(); | 367 DCHECK(IsValid()); |
| 368 return false; | 368 return false; |
| 369 } | 369 } |
| 370 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) | 370 #endif // !defined(OS_LINUX) |
| 371 | 371 |
| 372 int Process::GetPriority() const { | 372 int Process::GetPriority() const { |
| 373 DCHECK(IsValid()); | 373 DCHECK(IsValid()); |
| 374 return getpriority(PRIO_PROCESS, process_); | 374 return getpriority(PRIO_PROCESS, process_); |
| 375 } | 375 } |
| 376 | 376 |
| 377 } // namespace base | 377 } // namespace base |
| OLD | NEW |