libcgroup_rs

Crates.iolibcgroup_rs
lib.rslibcgroup_rs
version0.1.0
sourcesrc
created_at2020-06-17 07:17:41.691357
updated_at2020-06-17 07:17:41.691357
descriptionC FFI libcgroup
homepage
repositoryhttps://github.com/MeteorGX/libcgroup_rs
max_upload_size
id254845
size279,222
MeteorCat (MeteorGX)

documentation

https://docs.rs/libcgroup_rs

README

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

Result

1:cpu:/foo

Resources created by CGroup are Used

Commit count: 0

cargo fmt