This source file includes following definitions.
- Current
- pid
- is_current
- Close
- Terminate
- IsProcessBackgrounded
- SetProcessBackgrounded
- CanBackgroundProcesses
- GetPriority
#include "base/process/process.h"
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include "base/logging.h"
#include "base/process/kill.h"
namespace base {
Process Process::Current() {
return Process(GetCurrentProcessHandle());
}
ProcessId Process::pid() const {
if (process_ == 0)
return 0;
return GetProcId(process_);
}
bool Process::is_current() const {
return process_ == GetCurrentProcessHandle();
}
void Process::Close() {
process_ = 0;
}
void Process::Terminate(int result_code) {
if (!process_)
return;
KillProcess(process_, result_code, false);
}
#if !defined(OS_LINUX)
bool Process::IsProcessBackgrounded() const {
return false;
}
bool Process::SetProcessBackgrounded(bool value) {
return false;
}
bool Process::CanBackgroundProcesses() {
return false;
}
#endif
int Process::GetPriority() const {
DCHECK(process_);
return getpriority(PRIO_PROCESS, process_);
}
}