Skip to content

Commit 80efb1d

Browse files
12paperbluca
authored andcommitted
login: fix session_kill(..., KILL_LEADER,...) (#35105)
`loginctl kill-session --kill-whom=leader <N>` (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. (cherry picked from commit 8254755) (cherry picked from commit c89c5d0)
1 parent 484d31a commit 80efb1d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/login/logind-session.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,10 +1336,20 @@ SessionState session_get_state(Session *s) {
13361336
int session_kill(Session *s, KillWho who, int signo) {
13371337
assert(s);
13381338

1339-
if (!s->scope)
1340-
return -ESRCH;
1339+
switch (who) {
1340+
1341+
case KILL_ALL:
1342+
if (!s->scope)
1343+
return -ESRCH;
1344+
1345+
return manager_kill_unit(s->manager, s->scope, KILL_ALL, signo, NULL);
13411346

1342-
return manager_kill_unit(s->manager, s->scope, who, signo, NULL);
1347+
case KILL_LEADER:
1348+
return pidref_kill(&s->leader, signo);
1349+
1350+
default:
1351+
assert_not_reached();
1352+
}
13431353
}
13441354

13451355
static int session_open_vt(Session *s, bool reopen) {

0 commit comments

Comments
 (0)