Open p5pRT opened 16 years ago
According to "perlfunc/close": --- If the file handle came from a piped open\, "close" ... waits for the process executing on the pipe to complete\, ... and implicitly puts the exit status value of that command into $?. ---
That's true while pipe is opened like "open( PIPE\, '-|' );". But if pipe is opened by "open2(\*PIPE\, ..." the "close" does not set $?. Here is a testcase:
---( testcase begins )---------- #!/usr/bin/perl -w use strict; use IPC::Open2;
my $chld_pid = open2( \*PIPE\, '\<&STDIN'\, '/bin/bash'\, '-c'\, 'exit 2' );
while(\
print "Chld exit status is $? after close(PIPE).\n"; # this prints: # Chld exit status is 0 after close(PIPE).
# ***** WRONG EXIT STATUS IS REPORTED ABOVE THIS LINE ******
waitpid( $chld_pid\, 0 ); print "Chld exit status is $? after waitpid($chld_pid).\n"; # this prints like: # Chld exit status is 512 after waitpid(29779). ---( testcase ends )----------
The same incorrect behaviour is also demonstrated by Perl 5.8.0 for Linux\, by ActiveState perl 5.10.0\, 5.8.0 for windows.
We expect "close( PIPE )" should always set $?\, as documented.
The behavior described by the requestor is still present in blead (5.25.2).
-- Respectfully\, Dan Collins
The RT System itself - Status changed from 'new' to 'open'
@dcollinsn - Status changed from 'open' to 'stalled'
Migrated from rt.perl.org#51548 (status was 'stalled')
Searchable as RT51548$