pub trait CgroupsCommandExt {
// Required method
fn cgroups(&mut self, cgroups: &[impl AsRef<Cgroup>]) -> &mut Self;
}
Expand description
This trait is designed to extend std::process::Command
type with helpers for Cgroups.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl CgroupsCommandExt for Command
impl CgroupsCommandExt for Command
Source§fn cgroups(&mut self, cgroups: &[impl AsRef<Cgroup>]) -> &mut Self
fn cgroups(&mut self, cgroups: &[impl AsRef<Cgroup>]) -> &mut Self
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()
);