authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-11-25 12:58:25-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-11-25 14:18:55-08:00
log775b48dd10c1af3f8d21f5bae3e0d2495dfcec67
tree0abd3571d14e0c29a9c4e53442c38158845f6333
parentaa5341bf85e2aab566ae235c24f85ddaf09e8aee

std.io.Poller: handle EPIPE as EOF

closes #17483

1 files changed, 4 insertions(+), 1 deletions(-)

lib/std/io.zig+4-1
......@@ -646,7 +646,10 @@ pub fn Poller(comptime StreamEnum: type) type {
646646 // always check if there's some data waiting to be read first.
647647 if (poll_fd.revents & posix.POLL.IN != 0) {
648648 const buf = try q.writableWithSize(bump_amt);
649 const amt = try posix.read(poll_fd.fd, buf);
649 const amt = posix.read(poll_fd.fd, buf) catch |err| switch (err) {
650 error.BrokenPipe => 0, // Handle the same as EOF.
651 else => |e| return e,
652 };
650653 q.update(amt);
651654 if (amt == 0) {
652655 // Remove the fd when the EOF condition is met.