]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
killall: show PID of processes killed in final killing spree
authorLennart Poettering <lennart@poettering.net>
Thu, 3 Mar 2022 17:31:48 +0000 (18:31 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Mar 2022 21:45:47 +0000 (22:45 +0100)
Let's show the PID of killed processes in all cases, to make debugging
easier.

See: https://lists.freedesktop.org/archives/systemd-devel/2022-March/047504.html

src/shared/killall.c

index 343c2dc42c08b3d59ca06a7cf171779dce8ad007..35180870a86b561118d909d37778eb557356a9b9 100644 (file)
@@ -81,15 +81,16 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) {
 static void log_children_no_yet_killed(Set *pids) {
         _cleanup_free_ char *lst_child = NULL;
         void *p;
+        int r;
 
         SET_FOREACH(p, pids) {
                 _cleanup_free_ char *s = NULL;
-                char fallback[DECIMAL_STR_MAX(pid_t)];
-
-                if (get_process_comm(PTR_TO_PID(p), &s) < 0)
-                        xsprintf(fallback, PID_FMT, PTR_TO_PID(p));
 
-                if (!strextend(&lst_child, ", ", s ?: fallback))
+                if (get_process_comm(PTR_TO_PID(p), &s) >= 0)
+                        r = strextendf(&lst_child, ", " PID_FMT " (%s)", PTR_TO_PID(p), s);
+                else
+                        r = strextendf(&lst_child, ", " PID_FMT, PTR_TO_PID(p));
+                if (r < 0)
                         return (void) log_oom();
         }