From 45b4c9bb28596bb6102c387a4b0e4fbb87c78155 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 14:27:42 -0300 Subject: tty: a kept session whose terminal goes before its first frame detaches, not ends: the reader that takes the daemon's ok starts before kept() waits on it The reader starts after the first frame, and a hangup handled in that frame had kept() wait its full 2 s for an `ok` nobody read, then end the session. test/daemon.py's killed stub hit it 2 times in 55 under load, and none in 95 after. Co-Authored-By: Claude Opus 5.5 --- src/tty/tty.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/tty') diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 31f62d34..d474e83a 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -1860,7 +1860,10 @@ const Shell = struct { }, .quit => { // The terminal went: a session the daemon keeps carries on - // without it, to be attached again. + // without it, to be attached again. Gone before the first + // frame, the reader that takes the daemon's `ok` (kept + // waits on it) is not started yet: started here. + daemon.watch(s.loop, deliverNote); if (daemon.kept()) { if (s.attached()) s.leaveTerminal(); return true; -- cgit v1.3