summaryrefslogtreecommitdiff
path: root/src/ninep/tree.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 23:10:45 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitbcd8388d74e29398cb528206b05fd9491a4d4153 (patch)
tree0ed295fc5aed44fd8e42038fea5b071b34941c33 /src/ninep/tree.zig
parent6398e62741815ff11fa0c6380d0e7cde0c294fb9 (diff)
downloadpardes-bcd8388d74e29398cb528206b05fd9491a4d4153.tar.gz
pardes-bcd8388d74e29398cb528206b05fd9491a4d4153.zip
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 <[email protected]>
Diffstat (limited to 'src/ninep/tree.zig')
-rw-r--r--src/ninep/tree.zig12
1 files changed, 8 insertions, 4 deletions
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].?;