summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 10:33:40 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commitd8382d6ea6692cf07ec6df5a7f2b86ad1f01a9df (patch)
tree0cafa5687f718e897c214ffbf9c02cc642b23006 /src/pardes.zig
parent60e40675c82efd17aa6bf31bc66c3f8f3f918360 (diff)
downloadpardes-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/pardes.zig')
-rw-r--r--src/pardes.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index fbc3e119..442a3a30 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3095,6 +3095,9 @@ pub const Effect = union(enum) {
write: struct { pane: u8, bytes: Buf(64) },
resize_pty: struct { pane: u8, cols: u16, rows: u16 },
signal_pty: struct { pane: u8, sig: PtySignal },
+ /// The terminal pane in this slot is gone: the shell hangs up its pty
+ /// and ends the shell, rather than leave it running with nobody to read.
+ close_pty: struct { pane: u8 },
open_link: Buf(256),
/// write this pane's file content to its path; the shell reads both off
/// the core (content is unbounded, effects are fixed-size values)
@@ -4129,6 +4132,7 @@ pub const Pardes = struct {
const watched = (if (pane.file) |f| f.output == null else false) or pane.hasPdf();
for (p.panes, 0..) |slot, id| if (slot == pane) {
if (watched) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } });
+ if (pane.isTerminal()) p.emit(.{ .close_pty = .{ .pane = @intCast(id) } });
ctlfs.events.noteRetire(p, pane);
// ...and so do bytes still queued for the pty it no longer has.
p.dropPendingWrite(id);
@@ -4522,6 +4526,7 @@ pub const Pardes = struct {
.write => |w| if (v.pty_write) |f| f(p.host.ctx, w.pane, w.bytes.slice()),
.resize_pty => |r| if (v.pty_resize) |f| f(p.host.ctx, r.pane, r.cols, r.rows),
.signal_pty => |s| if (v.pty_signal) |f| f(p.host.ctx, s.pane, s.sig),
+ .close_pty => |c| if (v.close_pty) |f| f(p.host.ctx, c.pane),
.open_link => |u| if (v.open_link) |f|
f(p.host.ctx, u.slice())
else