[][src]Trait cgroups_fs::CgroupsCommandExt

pub trait CgroupsCommandExt {
    fn cgroups(&mut self, cgroups: &[impl AsRef<Cgroup>]) -> &mut Self;
}

This trait is designed to extend std::process::Command type with helpers for Cgroups.

Required methods

fn cgroups(&mut self, cgroups: &[impl AsRef<Cgroup>]) -> &mut Self

Specifies the Cgroups the executed process will be put into on start.

Loading content...

Implementations on Foreign Types

impl CgroupsCommandExt for Command[src]

fn cgroups(&mut self, cgroups: &[impl AsRef<Cgroup>]) -> &mut Self[src]

Specifies the Cgroups the executed process will be put into on start.

Example

let my_cgroup = cgroups_fs::CgroupName::new("my-cgroup");
let my_memory_cgroup = cgroups_fs::AutomanagedCgroup::init(&my_cgroup, "memory").unwrap();

use cgroups_fs::CgroupsCommandExt;
let output = std::process::Command::new("echo")
    .arg("Hello world")
    .cgroups(&[&my_memory_cgroup])
    .output()
    .expect("Failed to execute command");

println!(
    "The echo process used {} bytes of RAM.",
    my_memory_cgroup.get_value::<u64>("memory.max_usage_in_bytes").unwrap()
);
Loading content...

Implementors

Loading content...