Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/Basics/Concurrency/AsyncProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down