From 3823fa2c577d440649a84af660e4d3b0c095d248 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 30 Apr 2024 12:38:58 +0100 Subject: [PATCH] Send SIGHUP since some programs ignore SIGTERM, from Eduardo Grajeda in GitHub issue 3958. --- compat/systemd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compat/systemd.c b/compat/systemd.c index 063474e3..bde372cc 100644 --- a/compat/systemd.c +++ b/compat/systemd.c @@ -144,6 +144,17 @@ systemd_move_pid_to_new_cgroup(pid_t pid, char **cause) goto finish; } + /* + * Make sure that the session shells are terminated with SIGHUP since + * bash and friends tend to ignore SIGTERM. + */ + r = sd_bus_message_append(m, "(sv)", "SendSIGHUP", "b", 1); + if (r < 0) { + xasprintf(cause, "failed to append to properties: %s", + strerror(-r)); + goto finish; + } + /* * Inherit the slice from the parent process, or default to * "app-tmux.slice" if that fails.