CGroup

Struct CGroup 

Source
pub struct CGroup { /* private fields */ }
Expand description

A single cgroup inside our tree of managed cgroups

The tree is not represented by a traditional tree data structure, as this is very complicated in Rust. Instead, the tree is “calculated” by the path alone.

Implementations§

Source§

impl CGroup

Source

pub fn new_root<P: AsRef<Path>>(path: P, name: &str) -> Result<Self>

Creates a new cgroup as the root of a sub-tree

path must be the path of an already existing cgroup

Source

pub fn import_root<P: AsRef<Path>>(path: P) -> Result<Self>

Imports an already existing cgroup as the root of a sub-tree

Source

pub fn new(&self, name: &str) -> Result<Self>

Creates a sub-cgroup inside this one

Source

pub fn new_threaded(&self, name: &str) -> Result<Self>

Creates a threaded sub-cgroup inside this one

Source

pub fn mv_proc(&self, pid: Pid) -> Result<()>

Moves a process to this cgroup

Source

pub fn mv_thread(&self, pid: Pid) -> Result<()>

Moves a thread to this cgroup

Source

pub fn get_pids(&self) -> Result<Vec<Pid>>

Returns all PIDs associated with this cgroup

Source

pub fn get_tids(&self) -> Result<Vec<Pid>>

Returns all TIDs associated with this cgroup

Source

pub fn populated(&self) -> Result<bool>

Checks whether this cgroup is populated

Source

pub fn frozen(&self) -> Result<bool>

Checks whether this cgroup is frozen

Source

pub fn freeze(&self) -> Result<()>

Freezes this cgroup (does nothing if already frozen)

Source

pub fn unfreeze(&self) -> Result<()>

Unfreezes this cgroup (does nothing if not frozen)

Source

pub fn kill(&self) -> Result<()>

Kills all processes in this cgroup and returns once this procedure is finished

Source

pub fn get_path(&self) -> PathBuf

Returns the path of this cgroup

Source

pub fn get_events_path(&self) -> PathBuf

Returns the path of the event file, which may be polled

Source

pub fn rm(&self) -> Result<()>

Kills all processes and removes the current cgroup

Trait Implementations§

Source§

impl Debug for CGroup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for CGroup

§

impl RefUnwindSafe for CGroup

§

impl Send for CGroup

§

impl Sync for CGroup

§

impl Unpin for CGroup

§

impl UnwindSafe for CGroup

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.