1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
13 // Return the current process's cgroup for the given subsystem.
14 func findCgroup(subsystem string) string {
15 subsys := []byte(subsystem)
16 cgroups, err := ioutil.ReadFile("/proc/self/cgroup")
20 for _, line := range bytes.Split(cgroups, []byte("\n")) {
21 toks := bytes.SplitN(line, []byte(":"), 4)
25 for _, s := range bytes.Split(toks[1], []byte(",")) {
26 if bytes.Compare(s, subsys) == 0 {
27 return string(toks[2])
31 log.Fatalf("subsystem %q not found in /proc/self/cgroup", subsystem)