Skip to content

Commit 8d1f187

Browse files
committed
fix(attach-cgroup): only attach to a cgroup if it is already set up
1 parent 6c5f6d1 commit 8d1f187

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/wrap.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,19 @@ impl AttachRequest {
643643
.cgroupfs
644644
.clone()
645645
.unwrap_or("/sys/fs/cgroup".to_string());
646-
let cgroot = CGroup::open(&cgbase)?;
647-
let subtree = cgroot.create_child(format!("styrolite-{}", self.identity()?))?;
646+
let name = format!("styrolite-{}", self.identity()?);
647+
648+
let mut path = PathBuf::from(&cgbase);
649+
path.push(&name);
650+
651+
if !path.exists() {
652+
return Ok(());
653+
}
654+
655+
let path_str = path
656+
.to_str()
657+
.ok_or(anyhow!("path is somehow not valid utf-8"))?;
658+
let subtree = CGroup::open(path_str)?;
648659

649660
debug!("binding supervisor (pid {pid}) to cgroup");
650661
subtree

0 commit comments

Comments
 (0)