oom_score.cpp
Go to the documentation of this file.
/*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#include <core/posix/linux/proc/process/oom_score.h>
#include <core/posix/process.h>
#include <fstream>
#include <sstream>
namespace core
{
namespace posix
{
namespace linux
{
namespace proc
{
namespace process
{
const posix::Process& operator>>(const posix::Process& process, OomScore& score)
{
std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score";
std::ifstream in(ss.str());
in >> score.value;
return process;
}
}
}
}
}
}
core::posix::linux::proc::process::OomScore::value
int value
Current OomScore as calculated by the kernel.
Definition: oom_score.h:52
core::posix::linux::proc::process::OomScore
Definition: oom_score.h:50
process.h
core
Definition: child_process.h:31
core::posix::Process::pid
virtual pid_t pid() const
Query the pid of the process.
Definition: process.cpp:59
core::posix::linux::proc::process::operator>>
const CORE_POSIX_DLL_PUBLIC posix::Process & operator>>(const posix::Process &process, OomAdj &adj)
Read the OomAdj value for a process instance.
Definition: oom_adj.cpp:55
oom_score.h
core::posix::Process
The Process class models a process and possible operations on it.
Definition: process.h:44