From 626025879a55add714a984b56fff18a0a92eef57 Mon Sep 17 00:00:00 2001 From: Dave Inglis Date: Fri, 21 Nov 2025 15:43:13 -0500 Subject: [PATCH] Change AsyncProcess stdout/err reads to 4096 instead of Int.max - this should allow us to consume available in the Pipe as its filled and flushed but the running process. rdar://155634107 --- Sources/Basics/Concurrency/AsyncProcess.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Basics/Concurrency/AsyncProcess.swift b/Sources/Basics/Concurrency/AsyncProcess.swift index 17149e833bc..68898f7d099 100644 --- a/Sources/Basics/Concurrency/AsyncProcess.swift +++ b/Sources/Basics/Concurrency/AsyncProcess.swift @@ -517,7 +517,8 @@ package final class AsyncProcess { group.enter() stdoutPipe.fileHandleForReading.readabilityHandler = { (fh: FileHandle) in - let data = (try? fh.read(upToCount: Int.max)) ?? Data() + // 4096 is default pipe buffer size so reading in that size seems most efficient and still get output as it available + let data = (try? fh.read(upToCount: 4096)) ?? Data() if data.count == 0 { stdoutPipe.fileHandleForReading.readabilityHandler = nil group.leave() @@ -532,7 +533,8 @@ package final class AsyncProcess { group.enter() stderrPipe.fileHandleForReading.readabilityHandler = { (fh: FileHandle) in - let data = (try? fh.read(upToCount: Int.max)) ?? Data() + // 4096 is default pipe buffer size so reading in that size seems most efficient and still get output as it available + let data = (try? fh.read(upToCount: 4096)) ?? Data() if data.count == 0 { stderrPipe.fileHandleForReading.readabilityHandler = nil group.leave()