Prevent Ly from zombifying when X.org is terminated (#807) (fixes #787)

If a compositor is running when exiting Xorg, the user is met with an unresponsive black screen without the ability to switch to a different TTY (the usual `Ctrl+Alt+F{1..6}`  chord doesn't do anything).
In addition, ly is displayed as a zombie process under `ps` and cannot be killed (observed by utilizing a preexisting ssh connection to the host).

Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/807
Reviewed-by: AnErrupTion <anerruption@disroot.org>
Co-authored-by: djsigmann <djsigmann@protonmail.com>
Co-committed-by: djsigmann <djsigmann@protonmail.com>
This commit is contained in:
djsigmann 2025-08-05 21:45:09 +02:00 committed by AnErrupTion
parent 7353e75d78
commit 73ecac67bf
1 changed files with 4 additions and 2 deletions

View File

@ -460,8 +460,10 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, options: AuthOptio
_ = std.posix.waitpid(xorg_pid, 0);
interop.xcb.xcb_disconnect(xcb);
std.posix.kill(x_pid, 0) catch return;
std.posix.kill(x_pid, std.posix.SIG.KILL) catch {};
// TODO: Find a more robust way to ensure that X has been terminated (pidfds?)
std.posix.kill(x_pid, std.posix.SIG.TERM) catch {};
std.Thread.sleep(std.time.ns_per_s * 1); // Wait 1 second before sending SIGKILL
std.posix.kill(x_pid, std.posix.SIG.KILL) catch return;
var status: c_int = 0;
_ = std.c.waitpid(x_pid, &status, 0);