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.
This is precisely the type of plumbing that a shell will do when you say 2>&1, except without the unportable syntax ;-)pipe CHILDREAD, CHILWRITE; defined( my $pid = fork ) or die "fork: $!"; if ( $pid ) { # read on CHILDREAD; } else { open STDERR, ">&CHILDWRITE"; open STDOUT, ">&CHILDWRITE"; exec( $somecmd ); }
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
zz zZ Z Z #!perl
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Synchronizing STDERR and STDOUT
by Ovid (Cardinal) on Sep 21, 2006 at 11:12 UTC | |
by nothingmuch (Priest) on Sep 21, 2006 at 11:20 UTC |
In Section
Seekers of Perl Wisdom