Skip to content

Commit 4f2d422

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) (cherry picked from commit 80efb1d) (cherry picked from commit 94b234d) (cherry picked from commit bf4d3b2)
1 parent 6c3d369 commit 4f2d422

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
@@ -1269,10 +1269,20 @@ SessionState session_get_state(Session *s) {
12691269
int session_kill(Session *s, KillWho who, int signo) {
12701270
assert(s);
12711271

1272-
if (!s->scope)
1273-
return -ESRCH;
1272+
switch (who) {
1273+
1274+
case KILL_ALL:
1275+
if (!s->scope)
1276+
return -ESRCH;
1277+
1278+
return manager_kill_unit(s->manager, s->scope, KILL_ALL, signo, NULL);
12741279

1275-
return manager_kill_unit(s->manager, s->scope, who, signo, NULL);
1280+
case KILL_LEADER:
1281+
return RET_NERRNO(kill(s->leader, signo));
1282+
1283+
default:
1284+
assert_not_reached();
1285+
}
12761286
}
12771287

12781288
static int session_open_vt(Session *s) {

0 commit comments

Comments
 (0)