From 8254755091847105c33e473c62cdc7621ed275bc Mon Sep 17 00:00:00 2001 From: 12paper <104864644+12paper@users.noreply.github.com> Date: Sun, 10 Nov 2024 03:13:39 +0100 Subject: [PATCH] login: fix session_kill(..., KILL_LEADER,...) (#35105) `loginctl kill-session --kill-whom=leader ` (or the D-Bus equivalent) doesn't work because logind ends up calling `KillUnit(..., "main", ...)` on a scope unit and these don't have a `MainPID` property. Here, I just make it send a signal to the `Leader` directly. --- src/login/logind-session.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 66b4eadf61..7f359864dc 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -1390,10 +1390,20 @@ SessionState session_get_state(Session *s) { int session_kill(Session *s, KillWhom whom, int signo) { assert(s); - if (!s->scope) - return -ESRCH; + switch (whom) { + + case KILL_ALL: + if (!s->scope) + return -ESRCH; + + return manager_kill_unit(s->manager, s->scope, KILL_ALL, signo, NULL); - return manager_kill_unit(s->manager, s->scope, whom, signo, NULL); + case KILL_LEADER: + return pidref_kill(&s->leader, signo); + + default: + assert_not_reached(); + } } static int session_open_vt(Session *s, bool reopen) { -- 2.25.1