X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b6d7efab2c4bffa3fabd55b166e44cca8ac1391f..571e3176596b852c2f1385487e459126c3d3fd04:/lib/crunchrun/cgroup.go diff --git a/lib/crunchrun/cgroup.go b/lib/crunchrun/cgroup.go index 0b254f5bd7..48ec93b876 100644 --- a/lib/crunchrun/cgroup.go +++ b/lib/crunchrun/cgroup.go @@ -6,16 +6,16 @@ package crunchrun import ( "bytes" + "fmt" "io/ioutil" - "log" ) // Return the current process's cgroup for the given subsystem. -func findCgroup(subsystem string) string { +func findCgroup(subsystem string) (string, error) { subsys := []byte(subsystem) cgroups, err := ioutil.ReadFile("/proc/self/cgroup") if err != nil { - log.Fatal(err) + return "", err } for _, line := range bytes.Split(cgroups, []byte("\n")) { toks := bytes.SplitN(line, []byte(":"), 4) @@ -24,10 +24,9 @@ func findCgroup(subsystem string) string { } for _, s := range bytes.Split(toks[1], []byte(",")) { if bytes.Compare(s, subsys) == 0 { - return string(toks[2]) + return string(toks[2]), nil } } } - log.Fatalf("subsystem %q not found in /proc/self/cgroup", subsystem) - return "" + return "", fmt.Errorf("subsystem %q not found in /proc/self/cgroup", subsystem) }