http://qs1969.pair.com?node_id=574100


in reply to Re^2: Synchronizing STDERR and STDOUT
in thread Synchronizing STDERR and STDOUT

You can split the fork and the exec up if open mashes them together too much.
pipe CHILDREAD, CHILWRITE; defined( my $pid = fork ) or die "fork: $!"; if ( $pid ) { # read on CHILDREAD; } else { open STDERR, ">&CHILDWRITE"; open STDOUT, ">&CHILDWRITE"; exec( $somecmd ); }
This is precisely the type of plumbing that a shell will do when you say 2>&1, except without the unportable syntax ;-)

That said, IPC::Run and friends already abstract all of this out, so there's no need to reinvent the wheel.

-nuffin
zz zZ Z Z #!perl