summaryrefslogtreecommitdiffstats
path: root/src/core/swap.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-01 15:15:06 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-02 14:01:25 +0200
commita232ebcc2cd3d5e16b0d0fb0be61549f25fb8239 (patch)
tree72c6764739a1b3f35e0125b0e5440c69f47e535f /src/core/swap.c
parentcore: add helper function to check job status (diff)
downloadsystemd-a232ebcc2cd3d5e16b0d0fb0be61549f25fb8239.tar.xz
systemd-a232ebcc2cd3d5e16b0d0fb0be61549f25fb8239.zip
core: add support for RestartKillSignal= to override signal used for restart jobs
v2: - if RestartKillSignal= is not specified, fall back to KillSignal=. This is necessary to preserve backwards compatibility (and keep KillSignal= generally useful).
Diffstat (limited to 'src/core/swap.c')
-rw-r--r--src/core/swap.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/core/swap.c b/src/core/swap.c
index 6d0cd51750..0924b35050 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -712,21 +712,32 @@ static void swap_enter_dead_or_active(Swap *s, SwapResult f) {
swap_enter_dead(s, f);
}
+static int state_to_kill_operation(Swap *s, SwapState state) {
+ if (state == SWAP_DEACTIVATING_SIGTERM) {
+ if (unit_has_job_type(UNIT(s), JOB_RESTART))
+ return KILL_RESTART;
+ else
+ return KILL_TERMINATE;
+ }
+
+ return KILL_KILL;
+}
+
static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
int r;
- KillOperation kop;
assert(s);
if (s->result == SWAP_SUCCESS)
s->result = f;
- if (state == SWAP_DEACTIVATING_SIGTERM)
- kop = KILL_TERMINATE;
- else
- kop = KILL_KILL;
- r = unit_kill_context(UNIT(s), &s->kill_context, kop, -1, s->control_pid, false);
+ r = unit_kill_context(UNIT(s),
+ &s->kill_context,
+ state_to_kill_operation(s, state),
+ -1,
+ s->control_pid,
+ false);
if (r < 0)
goto fail;