Struct cgroups_fs::Cgroup
source · pub struct Cgroup { /* private fields */ }
Expand description
A controller of a specific cgroups namespace.
This type supports a number of operations for manipulating with a cgroups namespace.
Implementations§
source§impl Cgroup
impl Cgroup
sourcepub fn new(cgroup_name: &CgroupName, subsystem: &str) -> Self
pub fn new(cgroup_name: &CgroupName, subsystem: &str) -> Self
Defines a cgroup relation.
Notes:
- It does not create any cgroups. It is just an API abstraction layer. Learn more about
Cgroup::create
,Cgroup::remove
, andAutomanagedCgroup::init
methods.
sourcepub fn create(&self) -> Result<()>
pub fn create(&self) -> Result<()>
Creates a cgroups namespace.
Notes:
- Keep in mind the usual filesystem permissions (owner, group, and mode bits).
sourcepub fn remove(&self) -> Result<()>
pub fn remove(&self) -> Result<()>
Removes a cgroups namespace.
Notes:
- This method will fail if there are nested cgroups.
- Keep in mind the usual filesystem permissions (owner, group, and mode bits).
sourcepub fn set_raw_value<V>(&self, key: &str, value: V) -> Result<()>where
V: AsRef<[u8]>,
pub fn set_raw_value<V>(&self, key: &str, value: V) -> Result<()>where
V: AsRef<[u8]>,
Sets a binary or string value to the cgroup control file.
sourcepub fn set_value<V>(&self, key: &str, value: V) -> Result<()>where
V: Copy + ToString,
pub fn set_value<V>(&self, key: &str, value: V) -> Result<()>where
V: Copy + ToString,
Sets a value to the cgroup control file.
sourcepub fn get_raw_value(&self, key: &str) -> Result<String>
pub fn get_raw_value(&self, key: &str) -> Result<String>
Gets a string value from cgroup control file.
sourcepub fn get_value<T>(&self, key: &str) -> Result<T>where
T: FromStr,
pub fn get_value<T>(&self, key: &str) -> Result<T>where
T: FromStr,
Gets a value from cgroup control file.
sourcepub fn kill_all_tasks(&self) -> Result<()>
pub fn kill_all_tasks(&self) -> Result<()>
Kills (SIGKILL) all the attached to the cgroup tasks.