in reply to Re: fork() && exit;
in thread fork() && exit;

my $PID = fork(); if ($PID) { # in the parent process } else { # in the child process }
Bzzzt! That should read:
my $PID = fork(); if ($PID) { # in the parent process } else { # in either the child process or the parent # process, depending on whether the fork() # succeeded or failed. }
Always, always, always check the return values of your system calls. And that includes fork.

Abigail

Replies are listed 'Best First'.
Re: Re: fork() && exit;
by stvn (Monsignor) on Feb 23, 2004 at 17:09 UTC

    Absolutely correct. I will now punish myself as all devout monks should do:

    Bad programmer,... sloppy code!..... sloppy code!... Bad!!

    I will now force myself to code in PHP for the next 2 weeks as further punishment for my sins.

    (I forget sometimes how dangerous simplifications are in the context of fork.)

    -stvn