Skip to content

Commit ad2fc22

Browse files
authored
Use read to read data from a FileHandle instead of availableData (#486)
Analogous fix to swiftlang/swift-package-manager#8047
1 parent 27042e9 commit ad2fc22

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/TSCBasic/Process/Process.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public final class Process {
575575

576576
group.enter()
577577
stdoutPipe.fileHandleForReading.readabilityHandler = { (fh : FileHandle) -> Void in
578-
let data = fh.availableData
578+
let data = (try? fh.read(upToCount: Int.max)) ?? Data()
579579
if (data.count == 0) {
580580
stdoutPipe.fileHandleForReading.readabilityHandler = nil
581581
group.leave()
@@ -590,7 +590,7 @@ public final class Process {
590590

591591
group.enter()
592592
stderrPipe.fileHandleForReading.readabilityHandler = { (fh : FileHandle) -> Void in
593-
let data = fh.availableData
593+
let data = (try? fh.read(upToCount: Int.max)) ?? Data()
594594
if (data.count == 0) {
595595
stderrPipe.fileHandleForReading.readabilityHandler = nil
596596
group.leave()

0 commit comments

Comments
 (0)