From f0bdb082b05d35dc91ba9eb157009130dd813bc3 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Wed, 27 Apr 2016 19:16:19 +1000 Subject: [PATCH] main: fix bug in cgroup parsing Signed-off-by: Aleksa Sarai --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index cba1323..790abf7 100644 --- a/main.go +++ b/main.go @@ -302,7 +302,12 @@ func getCgroupsForPid(pid int) (map[string]string, error) { continue } - ret[line[1]] = line[2] + // For cgroups like "cpu,cpuacct" the ordering isn't guaranteed to be + // the same as the /sys/fs/cgroup dentry. But the kernel provides symlinks + // for each of the comma-separated components. + for _, part := range strings.Split(line[1], ",") { + ret[part] = line[2] + } } if err := scanner.Err(); err != nil {