Skip to content

Commit 94ce42b

Browse files
committed
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
1 parent 3a0692e commit 94ce42b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/shared/killall.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) {
8181
static void log_children_no_yet_killed(Set *pids) {
8282
_cleanup_free_ char *lst_child = NULL;
8383
void *p;
84+
int r;
8485

8586
SET_FOREACH(p, pids) {
8687
_cleanup_free_ char *s = NULL;
87-
char fallback[DECIMAL_STR_MAX(pid_t)];
88-
89-
if (get_process_comm(PTR_TO_PID(p), &s) < 0)
90-
xsprintf(fallback, PID_FMT, PTR_TO_PID(p));
9188

92-
if (!strextend(&lst_child, ", ", s ?: fallback))
89+
if (get_process_comm(PTR_TO_PID(p), &s) >= 0)
90+
r = strextendf(&lst_child, ", " PID_FMT " (%s)", PTR_TO_PID(p), s);
91+
else
92+
r = strextendf(&lst_child, ", " PID_FMT, PTR_TO_PID(p));
93+
if (r < 0)
9394
return (void) log_oom();
9495
}
9596

0 commit comments

Comments
 (0)