From 73ecac67bfbd819dad34cfdb30e16ca1c868bfdf Mon Sep 17 00:00:00 2001 From: djsigmann Date: Tue, 5 Aug 2025 21:45:09 +0200 Subject: [PATCH] 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 Co-authored-by: djsigmann Co-committed-by: djsigmann --- src/auth.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/auth.zig b/src/auth.zig index e57e237..f60f05e 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -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);