core/unit: modernize log_kill() too
This commit is contained in:
+8
-8
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user