From 9a347619d8940e7df640584814195bd57f94adcf Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 8 Sep 2023 11:13:50 +0200 Subject: [PATCH] utils: export MoveUnderCgroup Signed-off-by: Giuseppe Scrivano --- utils/utils_supported.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/utils_supported.go b/utils/utils_supported.go index ecd0c4c024..fe6472066e 100644 --- a/utils/utils_supported.go +++ b/utils/utils_supported.go @@ -47,7 +47,7 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error { // On errors check if the cgroup already exists, if it does move the process there if props, err := conn.GetUnitTypePropertiesContext(context.Background(), unitName, "Scope"); err == nil { if cgroup, ok := props["ControlGroup"].(string); ok && cgroup != "" { - if err := moveUnderCgroup(cgroup, "", []uint32{uint32(pid)}); err == nil { + if err := MoveUnderCgroup(cgroup, "", []uint32{uint32(pid)}); err == nil { return nil } // On errors return the original error message we got from StartTransientUnit. @@ -107,13 +107,13 @@ func GetCgroupProcess(pid int) (string, error) { // MoveUnderCgroupSubtree moves the PID under a cgroup subtree. func MoveUnderCgroupSubtree(subtree string) error { - return moveUnderCgroup("", subtree, nil) + return MoveUnderCgroup("", subtree, nil) } -// moveUnderCgroup moves a group of processes to a new cgroup. +// MoveUnderCgroup moves a group of processes to a new cgroup. // If cgroup is the empty string, then the current calling process cgroup is used. // If processes is empty, then the processes from the current cgroup are moved. -func moveUnderCgroup(cgroup, subtree string, processes []uint32) error { +func MoveUnderCgroup(cgroup, subtree string, processes []uint32) error { procFile := "/proc/self/cgroup" f, err := os.Open(procFile) if err != nil {