Skip to content

Commit bf9820e

Browse files
committed
Try run with IPC::Open3
1 parent e4643fa commit bf9820e

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

lib/Module/Release.pm

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ our $VERSION = '2.137';
3030
use Carp qw(carp croak);
3131
use File::Basename qw(dirname);
3232
use File::Spec;
33+
use IPC::Open3;
3334
use Scalar::Util qw(blessed);
35+
use Symbol 'gensym';
3436

3537
my %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
}

t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ subtest 'bad command' => sub {
6767
like $warnings, qr/'foo' is not recognized/, 'Saw Windows error';
6868
}
6969
else {
70-
like $at, qr/Could not open command/, "Error message with bad command";
70+
like $at, qr/exec of \Q$command\E failed/, "Error message with bad command";
7171
}
7272
};
7373

0 commit comments

Comments
 (0)