Commit 30a144a 1 parent 066a591 commit 30a144a Copy full SHA for 30a144a
File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -184,18 +184,18 @@ impl CommandExt for Command {
184
184
. stderr ( Stdio :: piped ( ) )
185
185
. spawn ( ) ?;
186
186
187
- let status = process. wait ( ) ?;
188
-
189
- // Read up to 256 bytes from stderr.
187
+ // Consume all stderr - it's open just for a few programs which can't handle it being closed.
190
188
use std:: io:: Read ;
191
189
let mut stderr = vec ! [ 0 ; 256 ] ;
192
- let len = process
193
- . stderr
194
- . take ( )
195
- . and_then ( |mut err| err. read ( & mut stderr) . ok ( ) )
196
- . unwrap_or ( 0 ) ;
190
+ let mut stderr_src = process. stderr . take ( ) . expect ( "piped stderr" ) ;
191
+
192
+ let len = stderr_src. read ( & mut stderr) . unwrap_or ( 0 ) ;
197
193
stderr. truncate ( len) ;
198
194
195
+ // consume the rest to avoid blocking
196
+ std:: io:: copy ( & mut stderr_src, & mut std:: io:: sink ( ) ) . ok ( ) ;
197
+
198
+ let status = process. wait ( ) ?;
199
199
Ok ( Output {
200
200
status,
201
201
stderr,
You can’t perform that action at this time.
0 commit comments