Crates.io | libcgroup_rs |
lib.rs | libcgroup_rs |
version | 0.1.0 |
source | src |
created_at | 2020-06-17 07:17:41.691357 |
updated_at | 2020-06-17 07:17:41.691357 |
description | C FFI libcgroup |
homepage | |
repository | https://github.com/MeteorGX/libcgroup_rs |
max_upload_size | |
id | 254845 |
size | 279,222 |
Rust library for managing control groups under Linux
[dependencies]
log = "*"
env_logger = "*"
libcgroup_rs = {version = "*"}
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(())
}
1:cpu:/foo
Resources created by CGroup are Used