Skip to content

Commit 107c7fd

Browse files
committed
[Utility] Read buffer of fast-exited command
1 parent 664b64a commit 107c7fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Utility/popen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public func popen(_ arguments: [String], redirectStandardError: Bool = false, en
5151

5252
task.launch()
5353

54-
while task.isRunning {
54+
repeat {
5555
guard let output = String(data: pipe.fileHandleForReading.availableData, encoding: NSUTF8StringEncoding) else {
5656
throw Error.UnicodeDecodingError
5757
}
5858
body(output)
59-
}
59+
} while task.isRunning
6060

6161
guard task.terminationStatus == 0 else {
6262
throw POSIX.Error.ExitStatus(task.terminationStatus, task.launchPath!, arguments)

0 commit comments

Comments
 (0)