From 775b48dd10c1af3f8d21f5bae3e0d2495dfcec67 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 25 Nov 2024 12:58:25 -0800 Subject: [PATCH] std.io.Poller: handle EPIPE as EOF closes #17483 --- lib/std/io.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/std/io.zig b/lib/std/io.zig index 0a9b2bf867..640f575654 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -646,7 +646,10 @@ pub fn Poller(comptime StreamEnum: type) type { // always check if there's some data waiting to be read first. if (poll_fd.revents & posix.POLL.IN != 0) { const buf = try q.writableWithSize(bump_amt); - const amt = try posix.read(poll_fd.fd, buf); + const amt = posix.read(poll_fd.fd, buf) catch |err| switch (err) { + error.BrokenPipe => 0, // Handle the same as EOF. + else => |e| return e, + }; q.update(amt); if (amt == 0) { // Remove the fd when the EOF condition is met.