Skip to content

Instantly share code, notes, and snippets.

@rwstauner
Created April 30, 2012 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwstauner/2559702 to your computer and use it in GitHub Desktop.
Save rwstauner/2559702 to your computer and use it in GitHub Desktop.
trying to figure out win32 STDIN hang with IPC::Open2
$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;
}
warn "STARTING\n";
# this prints first line but not second... without neither print
$|=1 if @ARGV;
$fh = \*STDIN; while(defined($_ = <$fh>)){ print qq[ $_] }
@rwstauner
Copy link
Author

main.pl hangs
main.pl 1 prints the first line, then hangs
main.pl 2 prints the first line (not the 2nd) and exits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment