@@ -30,7 +30,9 @@ our $VERSION = '2.137';
3030use Carp qw( carp croak) ;
3131use File::Basename qw( dirname) ;
3232use File::Spec;
33+ use IPC::Open3;
3334use Scalar::Util qw( blessed) ;
35+ use Symbol ' gensym' ;
3436
3537my %Loaded_mixins = ( );
3638
@@ -1321,24 +1323,43 @@ sub run {
13211323 $self -> _debug( " $command \n " );
13221324 $self -> _die( " Didn't get a command!" ) unless defined $command ;
13231325
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;
13261336
13271337 my $output = ' ' ;
1338+ my $error = ' ' ;
13281339 my $buffer = ' ' ;
13291340 local $| = 1;
13301341
13311342 my $readlen = $self -> debug ? 1 : 256;
13321343
1333- while ( read $fh , $buffer , $readlen ) {
1334- $output .= $_ ;
1344+ while ( read $child_out , $buffer , $readlen ) {
13351345 $self -> _debug( $_ , $buffer );
13361346 $output .= $buffer ;
13371347 }
13381348
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+ }
13391357 $self -> _debug( $self -> _dashes, " \n " );
13401358
1341- unless ( close $fh ) {
1359+ waitpid ( $pid , 0 );
1360+ my $child_exit_status = $? >> 8;
1361+
1362+ if ( $child_exit_status ) {
13421363 $self -> _run_error_set;
13431364 $self -> _warn( " Command [$command ] didn't close cleanly: $? " );
13441365 }
0 commit comments