On 6/30/06, Mumia W. <[EMAIL PROTECTED]> wrote:
In the parent, I want to redirect STDOUT to 'logfile' then fork. In the child, I want to print something. That something should end up in the log file, but it's not working.
my $child = fork(); exit ($child ? parent() : child() );
It's good to check whether the fork returned undef due to a failed fork.
sub parent { close STDOUT; open (STDOUT, '>', 'logfile') or die("Couldn't redirect STDOUT: $!\n");
If this happens only in the parent, it won't affect the child, as you've found.
I need to setup the redirection before I fork, but I shouldn't redirect from within the child,
Why don't you set up the redirection after the fork? Why shouldn't you do the redirection from the child process? That's how I always do it. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>