3232public func run<
3333 Input: InputProtocol ,
3434 Output: OutputProtocol ,
35- Error: OutputProtocol
35+ Error: ErrorOutputProtocol
3636> (
3737 _ executable: Executable ,
3838 arguments: Arguments = [ ] ,
@@ -74,7 +74,7 @@ public func run<
7474public func run<
7575 InputElement: BitwiseCopyable ,
7676 Output: OutputProtocol ,
77- Error: OutputProtocol
77+ Error: ErrorOutputProtocol
7878> (
7979 _ executable: Executable ,
8080 arguments: Arguments = [ ] ,
@@ -117,7 +117,7 @@ public func run<
117117/// - isolation: the isolation context to run the body closure.
118118/// - body: The custom execution body to manually control the running process
119119/// - Returns: an `ExecutableResult` type containing the return value of the closure.
120- public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: OutputProtocol > (
120+ public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: ErrorOutputProtocol > (
121121 _ executable: Executable ,
122122 arguments: Arguments = [ ] ,
123123 environment: Environment = . inherit,
@@ -164,7 +164,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol, Error: Out
164164/// - isolation: the isolation context to run the body closure.
165165/// - body: The custom execution body to manually control the running process.
166166/// - Returns: an `ExecutableResult` type containing the return value of the closure.
167- public func run< Result, Input: InputProtocol , Error: OutputProtocol > (
167+ public func run< Result, Input: InputProtocol , Error: ErrorOutputProtocol > (
168168 _ executable: Executable ,
169169 arguments: Arguments = [ ] ,
170170 environment: Environment = . inherit,
@@ -257,7 +257,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
257257/// - isolation: the isolation context to run the body closure.
258258/// - body: The custom execution body to manually control the running process
259259/// - Returns: An `ExecutableResult` type containing the return value of the closure.
260- public func run< Result, Error: OutputProtocol > (
260+ public func run< Result, Error: ErrorOutputProtocol > (
261261 _ executable: Executable ,
262262 arguments: Arguments = [ ] ,
263263 environment: Environment = . inherit,
@@ -391,7 +391,7 @@ public func run<Result>(
391391public func run<
392392 InputElement: BitwiseCopyable ,
393393 Output: OutputProtocol ,
394- Error: OutputProtocol
394+ Error: ErrorOutputProtocol
395395> (
396396 _ configuration: Configuration ,
397397 input: borrowing Span < InputElement > ,
@@ -451,7 +451,7 @@ public func run<
451451public func run<
452452 Input: InputProtocol ,
453453 Output: OutputProtocol ,
454- Error: OutputProtocol
454+ Error: ErrorOutputProtocol
455455> (
456456 _ configuration: Configuration ,
457457 input: Input = . none,
@@ -463,10 +463,13 @@ public func run<
463463 standardOutput: Output . OutputType ,
464464 standardError: Error . OutputType
465465 )
466+ let inputPipe = try input. createPipe ( )
467+ let outputPipe = try output. createPipe ( )
468+ let errorPipe = try error. createPipe ( from: outputPipe)
466469 let result = try await configuration. run (
467- input: try input . createPipe ( ) ,
468- output: try output . createPipe ( ) ,
469- error: try error . createPipe ( )
470+ input: inputPipe ,
471+ output: outputPipe ,
472+ error: errorPipe
470473 ) { ( execution, inputIO, outputIO, errorIO) -> RunResult in
471474 // Write input, capture output and error in parallel
472475 var inputIOBox : IOChannel ? = consume inputIO
@@ -540,18 +543,21 @@ public func run<
540543/// - body: The custom execution body to manually control the running process
541544/// - Returns an executableResult type containing the return value
542545/// of the closure.
543- public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: OutputProtocol > (
546+ public func run< Result, Input: InputProtocol , Output: OutputProtocol , Error: ErrorOutputProtocol > (
544547 _ configuration: Configuration ,
545548 input: Input = . none,
546549 output: Output = . discarded,
547550 error: Error = . discarded,
548551 isolation: isolated ( any Actor ) ? = #isolation,
549552 body: ( ( Execution ) async throws -> Result )
550553) async throws -> ExecutionResult < Result > where Error. OutputType == Void {
554+ let inputPipe = try input. createPipe ( )
555+ let outputPipe = try output. createPipe ( )
556+ let errorPipe = try error. createPipe ( from: outputPipe)
551557 return try await configuration. run (
552- input: try input . createPipe ( ) ,
553- output: try output . createPipe ( ) ,
554- error: try error . createPipe ( )
558+ input: inputPipe ,
559+ output: outputPipe ,
560+ error: errorPipe
555561 ) { execution, inputIO, outputIO, errorIO in
556562 var inputIOBox : IOChannel ? = consume inputIO
557563 return try await withThrowingTaskGroup (
@@ -590,7 +596,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol, Error: Out
590596/// - body: The custom execution body to manually control the running process
591597/// - Returns an executableResult type containing the return value
592598/// of the closure.
593- public func run< Result, Input: InputProtocol , Error: OutputProtocol > (
599+ public func run< Result, Input: InputProtocol , Error: ErrorOutputProtocol > (
594600 _ configuration: Configuration ,
595601 input: Input = . none,
596602 error: Error = . discarded,
@@ -599,10 +605,13 @@ public func run<Result, Input: InputProtocol, Error: OutputProtocol>(
599605 body: ( ( Execution , AsyncBufferSequence ) async throws -> Result )
600606) async throws -> ExecutionResult < Result > where Error. OutputType == Void {
601607 let output = SequenceOutput ( )
608+ let inputPipe = try input. createPipe ( )
609+ let outputPipe = try output. createPipe ( )
610+ let errorPipe = try error. createPipe ( from: outputPipe)
602611 return try await configuration. run (
603- input: try input . createPipe ( ) ,
604- output: try output . createPipe ( ) ,
605- error: try error . createPipe ( )
612+ input: inputPipe ,
613+ output: outputPipe ,
614+ error: errorPipe
606615 ) { execution, inputIO, outputIO, errorIO in
607616 var inputIOBox : IOChannel ? = consume inputIO
608617 var outputIOBox : IOChannel ? = consume outputIO
@@ -702,7 +711,7 @@ public func run<Result, Input: InputProtocol, Output: OutputProtocol>(
702711/// - body: The custom execution body to manually control the running process
703712/// - Returns an executableResult type containing the return value
704713/// of the closure.
705- public func run< Result, Error: OutputProtocol > (
714+ public func run< Result, Error: ErrorOutputProtocol > (
706715 _ configuration: Configuration ,
707716 error: Error = . discarded,
708717 preferredBufferSize: Int ? = nil ,
@@ -711,10 +720,13 @@ public func run<Result, Error: OutputProtocol>(
711720) async throws -> ExecutionResult < Result > where Error. OutputType == Void {
712721 let input = CustomWriteInput ( )
713722 let output = SequenceOutput ( )
723+ let inputPipe = try input. createPipe ( )
724+ let outputPipe = try output. createPipe ( )
725+ let errorPipe = try error. createPipe ( from: outputPipe)
714726 return try await configuration. run (
715- input: try input . createPipe ( ) ,
716- output: try output . createPipe ( ) ,
717- error: try error . createPipe ( )
727+ input: inputPipe ,
728+ output: outputPipe ,
729+ error: errorPipe
718730 ) { execution, inputIO, outputIO, errorIO in
719731 let writer = StandardInputWriter ( diskIO: inputIO!)
720732 let outputSequence = AsyncBufferSequence (
0 commit comments