From a74c44ba960315662c2d4b35ef4dd94b11292bfc Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 7 Mar 2024 02:28:23 -0800 Subject: [PATCH] Handle EPipe and avoid big data --- src/io/PipeWriter.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/io/PipeWriter.zig b/src/io/PipeWriter.zig index fb5e23ae68..fb85d95bf7 100644 --- a/src/io/PipeWriter.zig +++ b/src/io/PipeWriter.zig @@ -46,6 +46,10 @@ pub fn PosixPipeWriter( return .{ .pending = buf_.len - buf.len }; } + if (err.getErrno() == .PIPE) { + return .{ .done = buf_.len - buf.len }; + } + return .{ .err = err }; }, @@ -87,14 +91,13 @@ pub fn PosixPipeWriter( const buffer = getBuffer(parent); if (buffer.len == 0 and !received_hup) { - onWrite(parent, 0, false); return; } switch (drainBufferedData( parent, buffer, - if (size_hint > 0) @intCast(size_hint) else std.math.maxInt(usize), + if (size_hint > 0 and getFileType(parent).isBlocking()) @intCast(size_hint) else std.math.maxInt(usize), received_hup, )) { .pending => |wrote| {