pub struct CgroupGuard { /* private fields */ }Expand description
A per-run child cgroup. Placing the root subagent here puts its whole subtree
in the cgroup (membership inherits across fork), so kill_all tears the
entire subtree down atomically. RAII: Drop kills + removes the cgroup.
Implementations§
Source§impl CgroupGuard
impl CgroupGuard
Sourcepub fn for_run() -> Option<CgroupGuard>
pub fn for_run() -> Option<CgroupGuard>
Create the per-run child cgroup under the configured parent, applying the
configured hard limits, or None when the feature is off / creation fails
(best-effort, never an error).
Sourcepub fn apply_limits(&self, limits: &Limits) -> (bool, bool)
pub fn apply_limits(&self, limits: &Limits) -> (bool, bool)
Write the configured hard limits onto this leaf’s memory.max/pids.max.
Best-effort: a write no-ops where the controller wasn’t delegated (the
interface file is absent / read-only), so the run keeps cgroup.kill
teardown without the limit. Returns (memory_ok, pids_ok) for logging.
Sourcepub fn place(&self, pid: i32) -> bool
pub fn place(&self, pid: i32) -> bool
Move pid (and, by inheritance, its future descendants) into this
cgroup by writing its cgroup.procs. Best-effort → returns success.
Sourcepub fn kill_all(&self) -> bool
pub fn kill_all(&self) -> bool
Atomically SIGKILL every process in the subtree via cgroup.kill — the
backstop beyond killpg/PDEATHSIG. Best-effort → returns success.
Sourcepub fn oom_kills(&self) -> Option<u64>
pub fn oom_kills(&self) -> Option<u64>
The oom_kill count from this leaf’s memory.events — how many of its
processes the kernel OOM-killed (i.e. hit memory.max). None when the
memory controller isn’t active (no limit / not delegated). Lets the
supervisor report a memory.max kill plainly instead of as a generic exit.