From d8382d6ea6692cf07ec6df5a7f2b86ad1f01a9df Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 10:33:40 -0300 Subject: 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 --- src/ninep/pty.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ninep/pty.zig') diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index eda6e9d0..f788b4f8 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -806,6 +806,18 @@ test "a run's answer says cut when its output's start is gone, and reads a bound try testing.expectEqualStrings("error out of memory\n", sh.answered(p, node, h, into)); } +test "closing a terminal pane asks its shell to hang up the pty" { + const p = try withTerm(testing.allocator); + defer p.deinit(); + _ = try th.newPane(p); + const closed = th.rmdir(p, Node.of(serialOf(p), .dir)); + try testing.expectEqual(Status.ok, closed.reply.status); + try testing.expect(closed.closed); + // A text pane has no shell to end. + const text = try th.newPane(p); + try testing.expect(!th.rmdir(p, Node.of(text, .dir)).closed); +} + test "the pty queue drops the oldest at its cap" { const gpa = testing.allocator; const p = try withTerm(gpa); -- cgit v1.3