Struct cgroups_fs::AutomanagedCgroup
source · pub struct AutomanagedCgroup { /* private fields */ }
Expand description
An automatically managed controller of a specific cgroups subsystem.
It is a wrapper around Cgroup
type which automatically creates (on init
) and removes
(on drop
) a cgroup in a given subsystem.
Since it is a wrapper, all the methods from Cgroup
type are directly available for
AutomanagedCgroup
instances.
Implementations§
source§impl AutomanagedCgroup
impl AutomanagedCgroup
sourcepub fn init(cgroup_name: &CgroupName, subsystem: &str) -> Result<Self>
pub fn init(cgroup_name: &CgroupName, subsystem: &str) -> Result<Self>
Inits a cgroup, which means that it creates a cgroup in a given subsystem.
Notes:
- If there is an existing cgroup, it will be recreated from scratch. If that is not what
you what, consider using
Cgroup
type instead. - The cgroup will be automatically removed once the
AutomanagedCgroup
instance is dropped.
Methods from Deref<Target = Cgroup>§
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.