authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-02-07 01:49:15-07:00
committergravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-02-07 01:49:15-07:00
log2cc33367ebee202462d6bef7f07120dd38ff6912
tree52823c74d01dc5a6933c97a3c11ea9156aa5dc2c
parent4fddb591e2377186ef942084cae2e93d5de448b3

fix bug when ReadFile returns synchronously in collectOutputWindows


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

lib/std/child_process.zig+3-1
...@@ -270,12 +270,14 @@ pub const ChildProcess = struct {...@@ -270,12 +270,14 @@ pub const ChildProcess = struct {
270 try buf.ensureTotalCapacity(new_capacity);270 try buf.ensureTotalCapacity(new_capacity);
271 const next_buf = buf.unusedCapacitySlice();271 const next_buf = buf.unusedCapacitySlice();
272 if (next_buf.len == 0) return .full;272 if (next_buf.len == 0) return .full;
273 const read_result = windows.kernel32.ReadFile(handle, next_buf.ptr, math.cast(u32, next_buf.len) catch maxInt(u32), null, overlapped);273 var read_bytes: u32 = undefined;
274 const read_result = windows.kernel32.ReadFile(handle, next_buf.ptr, math.cast(u32, next_buf.len) catch maxInt(u32), &read_bytes, overlapped);
274 if (read_result == 0) return switch (windows.kernel32.GetLastError()) {275 if (read_result == 0) return switch (windows.kernel32.GetLastError()) {
275 .IO_PENDING => .pending,276 .IO_PENDING => .pending,
276 .BROKEN_PIPE => .closed,277 .BROKEN_PIPE => .closed,
277 else => |err| windows.unexpectedError(err),278 else => |err| windows.unexpectedError(err),
278 };279 };
280 buf.items.len += read_bytes;
279 }281 }
280 }282 }
281283