Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the IPC-System-Simple CPAN distribution.

Report information
The Basics
Id: 48319
Status: resolved
Priority: 0/
Queue: IPC-System-Simple

People
Owner: PJF [...] cpan.org
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.18
Fixed in: (no value)



Subject: eval capture/capturex breaks print STDOUT
working examples first print 1, prints 2, warns 3 D:\>perl -MIPC::System::Simple -le" print 1; eval { system q(errorerror); }; print 2; warn 3" 1 'errorerror' is not recognized as an internal or external command, operable program or batch file. 2 3 at -e line 1. D:\>perl -MIPC::System::Simple=capture -le" print 1; eval { capture }; print 2; warn 3" 1 2 3 at -e line 1. D:\>perl -MIPC::System::Simple=capture -le" print 1; eval { capture $^X, qw( -e die ); }; print 2; warn 3" 1 Died at -e line 1. 2 3 at -e line 1. NON-working examples first print 1, warns 3 D:\> D:\>perl -MIPC::System::Simple=capture -le" print 1; eval { capture q(errorerror); }; print 2; warn 3" 1 3 at -e line 1. D:\>perl -MIPC::System::Simple=capturex -le" print 1; eval { capturex q(errorerror); }; print 2; warn 3" 1 3 at -e line 1. D:\>
The problem is at line 299. The _spawn_or_die() croaks in case of inability to start the program and thus skips the STDOUT restore. The line my $pid = _spawn_or_die($exe, "$command @args"); needs to be changed to something like my $pid = eval { _spawn_or_die($exe, "$command @args"); } or do { my $err = $@; # Now restore our STDOUT. open(STDOUT, '>&', $saved_stdout) ## no critic or croak sprintf (FAIL_PLUMBING,"Can't restore STDOUT", $!); die $err; # and rethrow };
On Mon Mar 15 13:35:24 2010, JENDA wrote: Show quoted text
> The problem is at line 299. The _spawn_or_die() croaks in case of > inability to start the program and thus skips the STDOUT restore.
Thank-you very much, and nicely spotted! This has been fixed in IPC::System::Simple 1.21, which should soon be available from a CPAN mirror near you. Appropriate attribution for the fixes has been included in the Changes file. Thank-you again for your help! Paul