| 1 |
use super::process::Process; |
| 2 |
use crate::{Current, ProcResult}; |
| 3 |
use procfs_core::CGroupControllers; |
| 4 |
pub use procfs_core::ProcessCGroups; |
| 5 |
|
| 6 |
impl Current for CGroupControllers { |
| 7 |
const PATH: &'static str = "/proc/cgroups"; |
| 8 |
} |
| 9 |
|
| 10 |
/// Information about the cgroup controllers that are compiled into the kernel |
| 11 |
/// |
| 12 |
/// (since Linux 2.6.24) |
| 13 |
pub fn cgroups() -> ProcResult<CGroupControllers> { |
| 14 |
CGroupControllers::current() |
| 15 |
} |
| 16 |
|
| 17 |
impl Process { |
| 18 |
/// Describes control groups to which the process with the corresponding PID belongs. |
| 19 |
/// |
| 20 |
/// The displayed information differs for cgroupsversion 1 and version 2 hierarchies. |
| 21 |
pub fn cgroups(&self) -> ProcResult<ProcessCGroups> { |
| 22 |
self.read("cgroup") |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
#[cfg(test)] |
| 27 |
mod tests { |
| 28 |
use super::*; |
| 29 |
|
| 30 |
#[test] |
| 31 |
fn test_cgroups() { |
| 32 |
let groups = cgroups().unwrap(); |
| 33 |
println!("{:?}", groups); |
| 34 |
} |
| 35 |
|
| 36 |
#[test] |
| 37 |
fn test_process_cgroups() { |
| 38 |
let myself = Process::myself().unwrap(); |
| 39 |
let groups = myself.cgroups(); |
| 40 |
println!("{:?}", groups); |
| 41 |
} |
| 42 |
} |