When you fork each program (parent and child) has its own copy of the STDOUT and STDERR handles. You capture the output in the usual way:
my @cmds = qw ( cmd1 cmd2 ); my $pid = fork(); defined $pid or die "fork $!\n"; if ( $pid ) { $parent_captures = `$cmds[0] 2>&1`; } else { $kid_captures = `$cmds[1] 2>&1`; }
You can probably open STDERR onto STDOUT before the fork and then just capture STDOUT as well but I don't do it that way.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: fork and stdout/stderr
by tachyon
in thread fork and stdout/stderr
by smimp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |