From bcd8388d74e29398cb528206b05fd9491a4d4153 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 23:10:45 -0300 Subject: An event reader whose pane closes reads EOF, not ENOENT A script following a pane's event in a loop ended in an error when the pane went, though nothing had gone wrong: the pane was simply done. A read on an event open whose pane has closed now answers no bytes, the end a pipe's reader sees when its writer goes, so cat and while-read end cleanly. pty/data keeps acme's answer. Co-Authored-By: Claude Opus 5.5 --- src/ninep/tree.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/ninep/tree.zig') diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 8c536c51..c71a706f 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1094,10 +1094,14 @@ fn readFile(p: *Pardes, req: Req, target: Target) Reply { // A run's answer outlives the pane it ran in. if (t.file == .pty_run and req.handle != 0) return pty.readRun(p, req); const id = p.paneBySerial(t.serial) orelse { - // An event or pty/data read the pane closed under: acme's - // answer to the same (editors/acme/xfid.c:1005). - if (openOf(p, req)) |o| if (o.what == .event or o.what == .pty_data) - return failText(req.tag, E.NOENT, e_shut_down); + // An event reader whose pane closed reads its end: there + // are no more records, as a pipe's writer gone is EOF, so + // `while read` and `cat` end cleanly. A pty/data read the + // pane closed under keeps acme's answer (xfid.c:1005). + if (openOf(p, req)) |o| { + if (o.what == .event) return .{ .tag = req.tag }; + if (o.what == .pty_data) return failText(req.tag, E.NOENT, e_shut_down); + } return Reply.fail(req.tag, E.NOENT); }; const pn = p.panes[id].?; -- cgit v1.3