From: Mike Yuan Date: Tue, 30 Jul 2024 19:44:36 +0000 (+0200) Subject: core/unit: modernize log_kill() too X-Git-Tag: v257-rc1~753^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ffa9490d663a74e941459432b2be139e93f2ff5;p=thirdparty%2Fsystemd.git core/unit: modernize log_kill() too --- diff --git a/src/core/unit.c b/src/core/unit.c index fa28f67f34e..c8c34fc0d9b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4683,21 +4683,24 @@ int unit_make_transient(Unit *u) { return 0; } +static bool ignore_leftover_process(const char *comm) { + return comm && comm[0] == '('; /* Most likely our own helper process (PAM?), ignore */ +} + static int log_kill(const PidRef *pid, int sig, void *userdata) { + const Unit *u = ASSERT_PTR(userdata); _cleanup_free_ char *comm = NULL; assert(pidref_is_set(pid)); (void) pidref_get_comm(pid, &comm); - /* Don't log about processes marked with brackets, under the assumption that these are temporary processes - only, like for example systemd's own PAM stub process. */ - if (comm && comm[0] == '(') + if (ignore_leftover_process(comm)) /* Although we didn't log anything, as this callback is used in unit_kill_context we must return 1 * here to let the manager know that a process was killed. */ return 1; - log_unit_notice(userdata, + log_unit_notice(u, "Killing process " PID_FMT " (%s) with signal SIG%s.", pid->pid, strna(comm), @@ -4712,6 +4715,7 @@ static int operation_to_signal( bool *ret_noteworthy) { assert(c); + assert(ret_noteworthy); switch (k) { @@ -5836,10 +5840,6 @@ int unit_prepare_exec(Unit *u) { return 0; } -static bool ignore_leftover_process(const char *comm) { - return comm && comm[0] == '('; /* Most likely our own helper process (PAM?), ignore */ -} - static int unit_log_leftover_process_start(const PidRef *pid, int sig, void *userdata) { const Unit *u = ASSERT_PTR(userdata); _cleanup_free_ char *comm = NULL;