Skip to content

Commit bdb84aa

Browse files
troughtonaciidgh
authored andcommitted
Fix stdout and stderr on Windows (since stdoutData and stderrData were never read)
1 parent 0ea41af commit bdb84aa

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Sources/TSCBasic/Process.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ public final class Process: ObjectIdentifierProtocol {
201201
/// The result of the process execution. Available after process is terminated.
202202
private var _result: ProcessResult?
203203

204-
#if os(Windows)
205-
private var stdoutData: [UInt8] = []
206-
private var stderrData: [UInt8] = []
207-
#endif
208-
209204
/// If redirected, stdout result and reference to the thread reading the output.
210205
private var stdout: (result: Result<[UInt8], Swift.Error>, thread: Thread?) = (.success([]), nil)
211206

@@ -304,12 +299,16 @@ public final class Process: ObjectIdentifierProtocol {
304299
stdoutPipe.fileHandleForReading.readabilityHandler = { (fh : FileHandle) -> Void in
305300
let contents = fh.readDataToEndOfFile()
306301
self.outputRedirection.outputClosures?.stdoutClosure([UInt8](contents))
307-
self.stdoutData += contents
302+
if case .success(let data) = self.stdout.result {
303+
self.stdout.result = .success(data + contents)
304+
}
308305
}
309306
stderrPipe.fileHandleForReading.readabilityHandler = { (fh : FileHandle) -> Void in
310307
let contents = fh.readDataToEndOfFile()
311308
self.outputRedirection.outputClosures?.stderrClosure([UInt8](contents))
312-
self.stderrData += contents
309+
if case .success(let data) = self.stderr.result {
310+
self.stderr.result = .success(data + contents)
311+
}
313312
}
314313
_process?.standardOutput = stdoutPipe
315314
_process?.standardError = stderrPipe

0 commit comments

Comments
 (0)