| 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> |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // On POSIX there are no privileges to set. | 250 // On POSIX there are no privileges to set. |
| 251 return Open(pid); | 251 return Open(pid); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // static | 254 // static |
| 255 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { | 255 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { |
| 256 DCHECK_NE(handle, GetCurrentProcessHandle()); | 256 DCHECK_NE(handle, GetCurrentProcessHandle()); |
| 257 return Process(handle); | 257 return Process(handle); |
| 258 } | 258 } |
| 259 | 259 |
| 260 #if !defined(OS_LINUX) | 260 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
| 261 // static | 261 // static |
| 262 bool Process::CanBackgroundProcesses() { | 262 bool Process::CanBackgroundProcesses() { |
| 263 return false; | 263 return false; |
| 264 } | 264 } |
| 265 #endif // !defined(OS_LINUX) | 265 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
| 266 | 266 |
| 267 bool Process::IsValid() const { | 267 bool Process::IsValid() const { |
| 268 return process_ != kNullProcessHandle; | 268 return process_ != kNullProcessHandle; |
| 269 } | 269 } |
| 270 | 270 |
| 271 ProcessHandle Process::Handle() const { | 271 ProcessHandle Process::Handle() const { |
| 272 return process_; | 272 return process_; |
| 273 } | 273 } |
| 274 | 274 |
| 275 Process Process::Duplicate() const { | 275 Process Process::Duplicate() const { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); | 354 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); |
| 355 } | 355 } |
| 356 | 356 |
| 357 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 357 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
| 358 // Record the event that this thread is blocking upon (for hang diagnosis). | 358 // Record the event that this thread is blocking upon (for hang diagnosis). |
| 359 base::debug::ScopedProcessWaitActivity process_activity(this); | 359 base::debug::ScopedProcessWaitActivity process_activity(this); |
| 360 | 360 |
| 361 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); | 361 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); |
| 362 } | 362 } |
| 363 | 363 |
| 364 #if !defined(OS_LINUX) | 364 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
| 365 bool Process::IsProcessBackgrounded() const { | 365 bool Process::IsProcessBackgrounded() const { |
| 366 // See SetProcessBackgrounded(). | 366 // See SetProcessBackgrounded(). |
| 367 DCHECK(IsValid()); | 367 DCHECK(IsValid()); |
| 368 return false; | 368 return false; |
| 369 } | 369 } |
| 370 | 370 |
| 371 bool Process::SetProcessBackgrounded(bool value) { | 371 bool Process::SetProcessBackgrounded(bool value) { |
| 372 // Not implemented for POSIX systems other than Linux. With POSIX, if we were | 372 // Not implemented for POSIX systems other than Linux and Mac. With POSIX, if |
| 373 // to lower the process priority we wouldn't be able to raise it back to its | 373 // we were to lower the process priority we wouldn't be able to raise it back |
| 374 // initial priority. | 374 // to its initial priority. |
| 375 NOTIMPLEMENTED(); | 375 NOTIMPLEMENTED(); |
| 376 return false; | 376 return false; |
| 377 } | 377 } |
| 378 #endif // !defined(OS_LINUX) | 378 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
| 379 | 379 |
| 380 int Process::GetPriority() const { | 380 int Process::GetPriority() const { |
| 381 DCHECK(IsValid()); | 381 DCHECK(IsValid()); |
| 382 return getpriority(PRIO_PROCESS, process_); | 382 return getpriority(PRIO_PROCESS, process_); |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace base | 385 } // namespace base |
| OLD | NEW |