From: Lennart Poettering Date: Thu, 3 Mar 2022 17:31:48 +0000 (+0100) Subject: killall: show PID of processes killed in final killing spree X-Git-Tag: v251-rc1~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94ce42bcb6288583bfa8995aa705d99a9221f47e;p=thirdparty%2Fsystemd.git killall: show PID of processes killed in final killing spree 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 --- diff --git a/src/shared/killall.c b/src/shared/killall.c index 343c2dc42c0..35180870a86 100644 --- a/src/shared/killall.c +++ b/src/shared/killall.c @@ -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(); }