]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: properly determine cgroups zombie processes belong to
authorLennart Poettering <lennart@poettering.net>
Fri, 17 Nov 2017 18:24:06 +0000 (19:24 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Nov 2017 10:54:08 +0000 (11:54 +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 a7964fb5a92c18c28a7b70c8171c9bc76ee31514..ae8f2d116042c01b2d7bd3c7d79f38ca640c1fbe 100644 (file)
@@ -1104,6 +1104,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;
         }