[−][src]Struct cgroups_fs::AutomanagedCgroup
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.
Methods
impl AutomanagedCgroup
[src]
pub fn init(cgroup_name: &CgroupName, subsystem: &str) -> Result<Self>
[src]
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>
pub fn create(&self) -> Result<()>
[src]
Creates a cgroups namespace.
Notes:
- Keep in mind the usual filesystem permissions (owner, group, and mode bits).
pub fn remove(&self) -> Result<()>
[src]
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).
pub fn set_raw_value<V>(&self, key: &str, value: V) -> Result<()> where
V: AsRef<[u8]>,
[src]
V: AsRef<[u8]>,
Sets a binary or string value to the cgroup control file.
pub fn set_value<V>(&self, key: &str, value: V) -> Result<()> where
V: Copy + ToString,
[src]
V: Copy + ToString,
Sets a value to the cgroup control file.
pub fn get_raw_value(&self, key: &str) -> Result<String>
[src]
Gets a string value from cgroup control file.
pub fn get_value<T>(&self, key: &str) -> Result<T> where
T: FromStr,
[src]
T: FromStr,
Gets a value from cgroup control file.
pub fn add_task(&self, pid: Pid) -> Result<()>
[src]
Attaches a task (thread) to the cgroup.
pub fn get_tasks(&self) -> Result<Vec<Pid>>
[src]
Lists tasks (threads) attached to the cgroup.
pub fn send_signal_to_all_tasks(&self, signal: Signal) -> Result<usize>
[src]
Sends a specified Unix Signal to all the tasks in the Cgroup.
pub fn kill_all_tasks(&self) -> Result<()>
[src]
please, use freezer
cgroup to implement kill_all_tasks
reliably (https://gitlab.com/dots.org.ua/ddots-runner/blob/d967ee3ba9de364dfb5a2e1a4f468586efb504f8/src/extensions/process.rs#L132-166)
Kills (SIGKILL) all the attached to the cgroup tasks.
WARNING: The naive implementation turned out to be not reliable enough for the fork-bomb
use-case. To implement a reliable kill_all
method, use freezer
Cgroup. It is decided to
move such extensions into a separate crate (to be announced).
Trait Implementations
impl Drop for AutomanagedCgroup
[src]
impl AsRef<Cgroup> for AutomanagedCgroup
[src]
impl Deref for AutomanagedCgroup
[src]
impl Debug for AutomanagedCgroup
[src]
Auto Trait Implementations
impl Send for AutomanagedCgroup
impl Sync for AutomanagedCgroup
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,