@@ -30,7 +30,9 @@ our $VERSION = '2.137';
30
30
use Carp qw( carp croak) ;
31
31
use File::Basename qw( dirname) ;
32
32
use File::Spec;
33
+ use IPC::Open3;
33
34
use Scalar::Util qw( blessed) ;
35
+ use Symbol ' gensym' ;
34
36
35
37
my %Loaded_mixins = ( );
36
38
@@ -1321,24 +1323,43 @@ sub run {
1321
1323
$self -> _debug( " $command \n " );
1322
1324
$self -> _die( " Didn't get a command!" ) unless defined $command ;
1323
1325
1324
- open my ($fh ), " -|" , " $command " or $self -> _die( " Could not open command [$command ]: $! " );
1325
- $fh -> autoflush;
1326
+ my $pid = IPC::Open3::open3(
1327
+ my $child_in , my $child_out , my $child_err = gensym,
1328
+ $command
1329
+ );
1330
+ close $child_in ;
1331
+
1332
+ $child_out -> autoflush;
1333
+
1334
+ # open my($fh), "-|", "$command" or $self->_die( "Could not open command [$command]: $!" );
1335
+ # $fh->autoflush;
1326
1336
1327
1337
my $output = ' ' ;
1338
+ my $error = ' ' ;
1328
1339
my $buffer = ' ' ;
1329
1340
local $| = 1;
1330
1341
1331
1342
my $readlen = $self -> debug ? 1 : 256;
1332
1343
1333
- while ( read $fh , $buffer , $readlen ) {
1334
- $output .= $_ ;
1344
+ while ( read $child_out , $buffer , $readlen ) {
1335
1345
$self -> _debug( $_ , $buffer );
1336
1346
$output .= $buffer ;
1337
1347
}
1338
1348
1349
+ while ( read $child_err , $buffer , $readlen ) {
1350
+ $self -> _debug( $_ , $buffer );
1351
+ $error .= $buffer ;
1352
+ }
1353
+
1354
+ if ( $error =~ m / exec of .*? failed| Windows/ x ) {
1355
+ $self -> _warn( " Could not run <$command >: $error " );
1356
+ }
1339
1357
$self -> _debug( $self -> _dashes, " \n " );
1340
1358
1341
- unless ( close $fh ) {
1359
+ waitpid ( $pid , 0 );
1360
+ my $child_exit_status = $? >> 8;
1361
+
1362
+ if ( $child_exit_status ) {
1342
1363
$self -> _run_error_set;
1343
1364
$self -> _warn( " Command [$command ] didn't close cleanly: $? " );
1344
1365
}
0 commit comments