No functional changes. Just refactoring.
if (m->result == MOUNT_SUCCESS)
m->result = f;
- r = unit_kill_context(
- UNIT(m),
- &m->kill_context,
- state_to_kill_operation(state),
- /* main_pid= */ NULL,
- &m->control_pid,
- /* main_pid_alien= */ false);
+ r = unit_kill_context(UNIT(m), state_to_kill_operation(state));
if (r < 0) {
log_unit_warning_errno(UNIT(m), r, "Failed to kill processes: %m");
goto fail;
else {
r = unit_kill_context(
UNIT(s),
- &s->kill_context,
state != SCOPE_STOP_SIGTERM ? KILL_KILL :
s->was_abandoned ? KILL_TERMINATE_AND_LOG :
- KILL_TERMINATE,
- /* main_pid= */ NULL,
- /* control_pid= */ NULL,
- /* main_pid_alien= */ false);
+ KILL_TERMINATE);
if (r < 0) {
log_unit_warning_errno(UNIT(s), r, "Failed to kill processes: %m");
goto fail;
(void) unit_enqueue_rewatch_pids(UNIT(s));
kill_operation = state_to_kill_operation(s, state);
- r = unit_kill_context(
- UNIT(s),
- &s->kill_context,
- kill_operation,
- &s->main_pid,
- &s->control_pid,
- s->main_pid_alien);
+ r = unit_kill_context(UNIT(s), kill_operation);
if (r < 0) {
log_unit_warning_errno(UNIT(s), r, "Failed to kill processes: %m");
goto fail;
if (s->result == SOCKET_SUCCESS)
s->result = f;
- r = unit_kill_context(
- UNIT(s),
- &s->kill_context,
- state_to_kill_operation(s, state),
- /* main_pid= */ NULL,
- &s->control_pid,
- /* main_pid_alien= */ false);
+ r = unit_kill_context(UNIT(s), state_to_kill_operation(s, state));
if (r < 0) {
log_unit_warning_errno(UNIT(s), r, "Failed to kill processes: %m");
goto fail;
if (s->result == SWAP_SUCCESS)
s->result = f;
- r = unit_kill_context(
- UNIT(s),
- &s->kill_context,
- state_to_kill_operation(s, state),
- /* main_pid= */ NULL,
- &s->control_pid,
- /* main_pid_alien= */ false);
+ r = unit_kill_context(UNIT(s), state_to_kill_operation(s, state));
if (r < 0) {
log_unit_warning_errno(UNIT(s), r, "Failed to kill processes: %m");
goto fail;
}
}
-int unit_kill_context(
- Unit *u,
- KillContext *c,
- KillOperation k,
- PidRef* main_pid,
- PidRef* control_pid,
- bool main_pid_alien) {
-
+int unit_kill_context(Unit *u, KillOperation k) {
bool wait_for_exit = false, send_sighup;
cg_kill_log_func_t log_func = NULL;
int sig, r;
assert(u);
- assert(c);
/* Kill the processes belonging to this unit, in preparation for shutting the unit down. Returns > 0
* if we killed something worth waiting for, 0 otherwise. Do not confuse with unit_kill_common()
* which is used for user-requested killing of unit processes. */
- if (c->kill_mode == KILL_NONE)
+ KillContext *c = unit_get_kill_context(u);
+ if (!c || c->kill_mode == KILL_NONE)
return 0;
bool noteworthy;
IN_SET(k, KILL_TERMINATE, KILL_TERMINATE_AND_LOG) &&
sig != SIGHUP;
+ bool is_alien;
+ PidRef *main_pid = unit_main_pid_full(u, &is_alien);
if (pidref_is_set(main_pid)) {
if (log_func)
log_func(main_pid, sig, u);
log_unit_warning_errno(u, r, "Failed to kill main process " PID_FMT " (%s), ignoring: %m", main_pid->pid, strna(comm));
} else {
- if (!main_pid_alien)
+ if (!is_alien)
wait_for_exit = true;
if (r != -ESRCH && send_sighup)
}
}
+ PidRef *control_pid = unit_control_pid(u);
if (pidref_is_set(control_pid)) {
if (log_func)
log_func(control_pid, sig, u);
int unit_write_setting(Unit *u, UnitWriteFlags flags, const char *name, const char *data);
int unit_write_settingf(Unit *u, UnitWriteFlags mode, const char *name, const char *format, ...) _printf_(4,5);
-int unit_kill_context(Unit *u, KillContext *c, KillOperation k, PidRef *main_pid, PidRef *control_pid, bool main_pid_alien);
+int unit_kill_context(Unit *u, KillOperation k);
int unit_make_transient(Unit *u);