From f30ee05b0609b8f3aa488c94f3ff21733ed37053 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 16:29:29 -0300 Subject: A command's exit is told once its output is in, by the pty's state, not a timer The watcher woke the host a second time 60 ms after the exit by its own clock while the grace was counted from the reap: a host busy for 10 ms missed it, and the tag said running for ever and Kill did nothing; and under load exit 0 could land before the last output. As decided, no timer: the exit is told once it is reaped and the pty says nothing is left (poll: no POLLIN, and no POLLHUP, which means the end of file is on its way behind the output), else at that end of file, checked after each chunk of output. The tty host checks inside its step so the frame shows it. The four hosts' copies are one host_io.takeExits/commandEof, which close a told command's pty at its end of file (the fd and the GUI's reader leaked when the exit came first). A finished command pane whose pty a job it left still holds is not reused, so that job is not hung up; and the reset before a reuse is SGR 0, not DECSTR, which ghostty's stream does not implement. Co-Authored-By: Claude Opus 5.5 --- src/panes.zig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/panes.zig') diff --git a/src/panes.zig b/src/panes.zig index 9234912f..29fe0cb0 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -113,6 +113,9 @@ pub const Pane = struct { /// shown `exit ?`). command_done: bool = false, command_status: ?u8 = null, + /// Its pty is still open: a job the command left in the background may + /// be printing to it, and a reuse would hang it up. + command_pty: bool = false, /// The shell a terminal runs when it is not the configured one (`Tty /// fish`), owned. shell: ?[]u8 = null, -- cgit v1.3