Struct cgroups_rs::Cgroup

source ·
pub struct Cgroup { /* private fields */ }
Expand description

A control group is the central structure to this crate.

What are control groups?

Lifting over from the Linux kernel sources:

Control Groups provide a mechanism for aggregating/partitioning sets of tasks, and all their future children, into hierarchical groups with specialized behaviour.

This crate is an attempt at providing a Rust-native way of managing these cgroups.

Implementations§

Create a new control group in the hierarchy hier, with name path.

Returns a handle to the control group that can be used to manipulate it.

Create a new control group in the hierarchy hier, with name path.

Returns a handle to the control group that can be used to manipulate it.

Create a new control group in the hierarchy hier, with name path and relative_paths

Returns a handle to the control group that can be used to manipulate it.

Note that this method is only meaningful for cgroup v1, call it is equivalent to call new in the v2 mode.

Create a handle for a control group in the hierarchy hier, with name path.

Returns a handle to the control group (that possibly does not exist until create() has been called on the cgroup.

Create a handle for a specified control group in the hierarchy hier, with name path.

Returns a handle to the control group (that possibly does not exist until create() has been called on the cgroup.

Create a handle for a control group in the hierarchy hier, with name path and relative_paths

Returns a handle to the control group (that possibly does not exist until create() has been called on the cgroup.

Note that this method is only meaningful for cgroup v1, call it is equivalent to call load in the v2 mode

The list of subsystems that this control group supports.

Deletes the control group.

Note that this function makes no effort in cleaning up the descendant and the underlying system call will fail if there are any descendants. Thus, one should check whether it was actually removed, and remove the descendants first if not. In the future, this behavior will change.

Apply a set of resource limits to the control group.

Retrieve a container based on type inference.

Example:
let pids: &PidController = control_group.controller_of()
                            .expect("No pids controller attached!");
let cpu: &CpuController = control_group.controller_of()
                            .expect("No cpu controller attached!");

Removes tasks from the control group by thread group id.

Note that this means that the task will be moved back to the root control group in the hierarchy and any rules applied to that control group will still apply to the proc.

Removes a task from the control group.

Note that this means that the task will be moved back to the root control group in the hierarchy and any rules applied to that control group will still apply to the task.

Moves tasks to the parent control group by thread group id.

Moves a task to the parent control group.

Return a handle to the parent control group in the hierarchy.

Kill every process in the control group. Only supported for v2 cgroups and on kernels 5.14+. This will fail with InvalidOperation if the ‘cgroup.kill’ file does not exist.

Attach a task to the control group.

Attach tasks to the control group by thread group id.

set cgroup.type

get cgroup.type

Set notify_on_release to the control group.

Set release_agent

Returns an Iterator that can be used to iterate over the procs that are currently in the control group.

Returns an Iterator that can be used to iterate over the tasks that are currently in the control group.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.