1 unstable release
0.1.0 | Jun 17, 2020 |
---|
#17 in #cgroup
210KB
1.5K
SLoC
libcgroup_rs
Rust library for managing control groups under Linux
Manual
Usage
Toml Package
[dependencies]
log = "*"
env_logger = "*"
libcgroup_rs = {version = "*"}
Rust Code
fn main()->Result<(),std::io::Error>{
env_logger::try_init()?;
// Initialize
CGroup::init()?;
info!("Mount Point = {:?}",CGroup::get_subsys_mount_point("cpu"));
// create cgroup container
let container_name = "container_test_work";
let mut cg = CGroupBuilder::new(container_name)?;
info!("Add Controller = {:?}",cg.add_controller("cpu")?);
info!("Get Controller = {:?}",cg.get_controller("cpu")?);
//cg.free_controllers();
//only root
cg.create(0)?;
// execute shell
cg.attach_task_shell()?;
Ok(())
}
Result
1:cpu:/foo
Resources created by CGroup are Used