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 {
611
611
break loop
612
612
}
613
613
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)
614
622
break loop
615
623
default :
616
624
let data = buf [ 0 ..< n]
@@ -621,8 +629,6 @@ public final class Process: ObjectIdentifierProtocol {
621
629
}
622
630
}
623
631
}
624
- // Close the read end of the output pipe.
625
- close ( fd)
626
632
// Construct the output result.
627
633
return error. map ( Result . failure) ?? . success( out)
628
634
}
You can’t perform that action at this time.
0 commit comments