Skip to content

Commit 74a6702

Browse files
jsturtevantmxpv
authored andcommitted
use process thread group id for the process
in cgroupv2 we should use the cgroups.proc file when adding a process (https://www.man7.org/linux/man-pages/man7/cgroups.7.html). The add_tasks function was writing to the cgroup.threads file which is only avaliable when in threaded mode. In either case our intent is to add the process not the individual threads to we should use add_task_by_tgid. See kata-containers/cgroups-rs#104 for when this was added Signed-off-by: James Sturtevant <jstur@microsoft.com>
1 parent 11a6559 commit 74a6702

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/shim/src/cgroup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn add_task_to_cgroup(path: &str, pid: u32) -> Result<()> {
6464
let path = path.trim_start_matches('/');
6565

6666
Cgroup::load(h, path)
67-
.add_task(CgroupPid::from(pid as u64))
67+
.add_task_by_tgid(CgroupPid::from(pid as u64))
6868
.map_err(other_error!(e, "add task to cgroup"))
6969
}
7070

@@ -310,7 +310,7 @@ mod tests {
310310
assert!(cg.tasks().contains(&cg_id));
311311

312312
// remove cgroup as possible
313-
cg.remove_task(cg_id).unwrap();
313+
cg.remove_task_by_tgid(cg_id).unwrap();
314314
cg.delete().unwrap()
315315
}
316316

0 commit comments

Comments
 (0)