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
3 // found in the LICENSE file.
5 #include "base/process.h"
9 #include <sys/resource.h>
11 #include "base/process_util.h"
12 #include "base/logging.h"
17 Process
Process::Current() {
18 return Process(GetCurrentProcessHandle());
21 ProcessId
Process::pid() const {
25 return GetProcId(process_
);
28 bool Process::is_current() const {
29 return process_
== GetCurrentProcessHandle();
32 void Process::Close() {
34 // if the process wasn't terminated (so we waited) or the state
35 // wasn't already collected w/ a wait from process_utils, we're gonna
36 // end up w/ a zombie when it does finally exit.
39 void Process::Terminate(int result_code
) {
40 // result_code isn't supportable.
43 // We don't wait here. It's the responsibility of other code to reap the
45 KillProcess(process_
, result_code
, false);
48 #if !defined(OS_LINUX)
49 bool Process::IsProcessBackgrounded() const {
50 // See SetProcessBackgrounded().
54 bool Process::SetProcessBackgrounded(bool value
) {
55 // POSIX only allows lowering the priority of a process, so if we
56 // were to lower it we wouldn't be able to raise it back to its initial
62 bool Process::CanBackgroundProcesses() {
68 int Process::GetPriority() const {
70 return getpriority(PRIO_PROCESS
, process_
);