summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 15:13:48 -0300
committerGabriel Schneider <[email protected]>2026-11-20 15:18:43 -0300
commit0957cd7ad097c83a591e315f2e261996e72ea856 (patch)
tree1e13f10ab4b1fc809ec764217d53fb583946e4aa /dev
parente3d0daa9f89f41b41b7d05d510db553cbd8816d9 (diff)
downloadpardes-0957cd7ad097c83a591e315f2e261996e72ea856.tar.gz
pardes-0957cd7ad097c83a591e315f2e261996e72ea856.zip
tui: a pardes whose terminal hangs up (no daemon) or that is sent SIGTERM kills its language servers' groups as an exit does: Killed.handle dies by raise, so the language client's atexit group kill (lsp_client.zig killAllAtExit) never ran and a server busy in a build (zls at a cold start, its children) lived on after the editor; the handler calls it now (kill(2) only, async-signal-safe); test "tty editing: lsp-hangup" (the mock, LSPMOCK_MODE=busy, leaves a child in its group at the handshake and says its pid; the case hangs up the pty and wants the child gone in 5 s): ServerChildLivesOn on the base, passes now; a user could hit it: closing the terminal of a daemon-less pardes, or kill (TERM) of any pardes, with a language server busy; tui process-test 1 of 145 failed once in the whole run (the SIGTERM flags case, "the terminal left raw", load 8-15; 3 of 3 alone)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev')
-rw-r--r--dev/lsp/lsp_client.zig5
-rw-r--r--dev/tui/tui.zig4
2 files changed, 6 insertions, 3 deletions
diff --git a/dev/lsp/lsp_client.zig b/dev/lsp/lsp_client.zig
index 4ad8dace..fdd4af55 100644
--- a/dev/lsp/lsp_client.zig
+++ b/dev/lsp/lsp_client.zig
@@ -2244,8 +2244,9 @@ fn reap(pid: libc.pid_t) void {
/// At this process's exit, every server's group is killed: a server busy
/// in a build (zls at a cold start) would not notice its socket close, and
/// lived on with its children after the editor. Registered once, at the
-/// first spawn; signals only, no locks (other threads may hold them).
-fn killAllAtExit() callconv(.c) void {
+/// first spawn; signals only, no locks (other threads may hold them): a
+/// signal's handler calls it too (tui.zig `Killed`).
+pub fn killAllAtExit() callconv(.c) void {
for (&conns) |*c| if (c.pid > 0) {
_ = libc.kill(-c.pid, .KILL);
};
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index 72028b04..638f1400 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -906,7 +906,7 @@ const Screen = struct {
/// the main screen, no mouse, paste or keyboard modes, the cursor shown,
/// cooked termios -- and then the signal's own death. A nested editor
/// killed in a pane must not leave that pane's terminal wedged.
-/// Async-signal-safe: write, tcsetattr, sigaction, raise.
+/// Async-signal-safe: write, tcsetattr, kill, sigaction, raise.
const Killed = struct {
var fd: posix.fd_t = -1;
var cooked: posix.termios = undefined;
@@ -937,6 +937,8 @@ const Killed = struct {
ninep_io.unlinkOwnSocket();
host_io.Shell.unlinkOwnedRcs();
daemon.hangUp();
+ // No exit hook runs: the language servers' groups go here.
+ @import("../lsp/lsp_client.zig").killAllAtExit();
// SA_RESETHAND put the default back: the same signal, now fatal.
_ = std.c.raise(sig);
}