diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 10:33:40 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | d8382d6ea6692cf07ec6df5a7f2b86ad1f01a9df (patch) | |
| tree | 0cafa5687f718e897c214ffbf9c02cc642b23006 /src/tty | |
| parent | 60e40675c82efd17aa6bf31bc66c3f8f3f918360 (diff) | |
| download | pardes-d8382d6ea6692cf07ec6df5a7f2b86ad1f01a9df.tar.gz pardes-d8382d6ea6692cf07ec6df5a7f2b86ad1f01a9df.zip | |
A terminal pane that closes takes its shell and pty with it, in every front end
The detached server closed a pane's pty only when the shell was respawned,
hit EOF or the session shut down, so rmdir, Del or Delcol on a terminal
left its shell running with nobody to read it; the tty front end and
macOS did the same. Retiring a terminal pane now emits a close_pty
effect, which each host that runs shells answers by hanging the pty up
and ending the shell (the detached server's and the GUI's existing
retire-and-reap path, and a close plus SIGHUP in the tty and macOS
shells).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tty')
| -rw-r--r-- | src/tty/tty.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 903c5c0c..b2768ed6 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -924,6 +924,7 @@ const Shell = struct { .pty_write = ptyWrite, .pty_resize = ptyResize, .pty_signal = ptySignal, + .close_pty = closePty, .tty_taken = ttyTaken, .write_file = writeFile, .write_dump = writeDump, @@ -1227,6 +1228,20 @@ const Shell = struct { if (s.ptys[pane]) |pt| host_io.signalTty(pt.pid, pt.file.handle, sig); } + /// The pane is gone: hang its pty up, which the kernel passes on to the + /// shell as SIGHUP, and say it too for a shell that ignores the tty's. + /// Output still in flight carries the old generation and is dropped. + fn closePty(ctx: ?*anyopaque, pane: u8) void { + const s = of(ctx); + var pt = s.ptys[pane] orelse return; + s.ptys[pane] = null; + s.gens[pane] +%= 1; + pt.reader.cancel(s.io) catch {}; + _ = libc.close(pt.file.handle); + _ = libc.kill(pt.pid, posix.SIG.HUP); + _ = libc.waitpid(pt.pid, null, posix.W.NOHANG); + } + fn ttyTaken(ctx: ?*anyopaque, pane: u8) bool { const s = of(ctx); const pt = s.ptys[pane] orelse return false; |
