mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add get_threads
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
use izolilib::cgroup::cgroup::CGroup;
|
||||
|
||||
fn main() {
|
||||
let cgroup = CGroup::new("test").unwrap();
|
||||
let cgroup = CGroup::new("").unwrap();
|
||||
println!("{:?}", cgroup.get_root_path());
|
||||
println!("{}", cgroup.check_status());
|
||||
println!("{:?}", cgroup.read("cgroup.type"));
|
||||
println!("{:?}", cgroup.get_controllers());
|
||||
println!("{:?}", cgroup.get_subtree_control());
|
||||
println!("{:?}", cgroup.get_procs());
|
||||
println!("{:?}", cgroup.get_threads());
|
||||
println!("{:?}", cgroup.get_stat());
|
||||
}
|
||||
|
@ -76,8 +76,16 @@ impl CGroup {
|
||||
}
|
||||
|
||||
pub fn get_procs(&self) -> Result<Vec<u32>, std::io::Error> {
|
||||
self.get_u32_list("cgroup.procs")
|
||||
}
|
||||
|
||||
pub fn get_threads(&self) -> Result<Vec<u32>, std::io::Error> {
|
||||
self.get_u32_list("cgroup.threads")
|
||||
}
|
||||
|
||||
fn get_u32_list(&self, name: &str) -> Result<Vec<u32>, std::io::Error> {
|
||||
let procs = self
|
||||
.read("cgroup.procs")?
|
||||
.read(name)?
|
||||
.lines()
|
||||
.map(|proc| u32::from_str(proc.trim()).unwrap())
|
||||
.collect();
|
||||
|
Reference in New Issue
Block a user