File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -611,6 +611,14 @@ public final class Process: ObjectIdentifierProtocol {
611611 break loop
612612 }
613613 case 0 :
614+ // Close the read end of the output pipe.
615+ // We should avoid closing the read end of the pipe in case
616+ // -1 because the child process may still have content to be
617+ // flushed into the write end of the pipe. If the read end of the
618+ // pipe is closed, then a write will cause a SIGPIPE signal to
619+ // be generated for the calling process. If the calling process is
620+ // ignoring this signal, then write fails with the error EPIPE.
621+ close ( fd)
614622 break loop
615623 default :
616624 let data = buf [ 0 ..< n]
@@ -621,8 +629,6 @@ public final class Process: ObjectIdentifierProtocol {
621629 }
622630 }
623631 }
624- // Close the read end of the output pipe.
625- close ( fd)
626632 // Construct the output result.
627633 return error. map ( Result . failure) ?? . success( out)
628634 }
You can’t perform that action at this time.
0 commit comments