chiark / gitweb /
cgroup: properly determine cgroups zombie processes belong to
authorLennart Poettering <lennart@poettering.net>
Fri, 17 Nov 2017 18:24:06 +0000 (19:24 +0100)
committerSven Eden <yamakuzure@gmx.net>
Fri, 17 Nov 2017 18:24:06 +0000 (19:24 +0100)
When a process becomes a zombie its cgroup might be deleted. Let's add
some minimal code to detect cases like this, so that we can still
attribute this back to the original cgroup.

src/basic/cgroup-util.c

index 30bb4664fabfaa848174fb4cb870a998743bdf03..71b88f1d3b3d102e40cc26ac832cfecf939b5d12 100644 (file)
@@ -1118,6 +1118,11 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
                 if (!p)
                         return -ENOMEM;
 
+                /* Truncate suffix indicating the process is a zombie */
+                e = endswith(p, " (deleted)");
+                if (e)
+                        *e = 0;
+
                 *path = p;
                 return 0;
         }