From 2cc33367ebee202462d6bef7f07120dd38ff6912 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Mon, 7 Feb 2022 01:49:15 -0700 Subject: [PATCH] fix bug when ReadFile returns synchronously in collectOutputWindows --- lib/std/child_process.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 10aeacf755..ace58ecf4f 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -270,12 +270,14 @@ pub const ChildProcess = struct { try buf.ensureTotalCapacity(new_capacity); const next_buf = buf.unusedCapacitySlice(); if (next_buf.len == 0) return .full; - const read_result = windows.kernel32.ReadFile(handle, next_buf.ptr, math.cast(u32, next_buf.len) catch maxInt(u32), null, overlapped); + var read_bytes: u32 = undefined; + const read_result = windows.kernel32.ReadFile(handle, next_buf.ptr, math.cast(u32, next_buf.len) catch maxInt(u32), &read_bytes, overlapped); if (read_result == 0) return switch (windows.kernel32.GetLastError()) { .IO_PENDING => .pending, .BROKEN_PIPE => .closed, else => |err| windows.unexpectedError(err), }; + buf.items.len += read_bytes; } }