Created
April 30, 2012 16:18
-
-
Save rwstauner/2559702 to your computer and use it in GitHub Desktop.
trying to figure out win32 STDIN hang with IPC::Open2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$arg = ' ' . shift @ARGV; | |
$script = qq[perl pipe1.pl $arg]; | |
system(q{perl -e "print qq[hi$/there$/]" | } . $script); | |
use IPC::Open2 "open2"; | |
$pid = open2($out, $in, $script); | |
$|=1; | |
print $in qq[hi$/there$/]; | |
close $in; | |
print scalar <$out>; | |
unless( $arg =~ /2/ ){ | |
close $out; | |
waitpid $pid, 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
warn "STARTING\n"; | |
# this prints first line but not second... without neither print | |
$|=1 if @ARGV; | |
$fh = \*STDIN; while(defined($_ = <$fh>)){ print qq[ $_] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
main.pl
hangsmain.pl 1
prints the first line, then hangsmain.pl 2
prints the first line (not the 2nd) and exits