in reply to Re: Confused by fork examples
in thread Confused by fork examples

ambrus,
To quote the docs: It returns the child pid to the parent process, 0 to the child process, or undef if the fork is unsuccessful.

I believe the 3rd block would be executed if fork failed because it would return undef not 0?

Update: Specifically, I am referring to your comment If fork gives an error, it will execute the first body; the third body is never executed. I now see your point. If the $pid is undef then ($pid == 0) won't work as intended. Thanks.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Confused by fork examples
by MidLifeXis (Monsignor) on Feb 20, 2009 at 18:20 UTC

    In the CB, you were looking for documentation that I know I had seen in the past. mr_mischief jogged my memory as to where it was.

    • pink camel, under fork() (page 146)
    • blue camel, under fork() (page 167)

    hth

    --MidLifeXis

      For those with the Perl CD Bookshelf (which has no page numbers for the electronic-only versions) the 3rd Edition of the Camel has what I think we're talking about in section 29.2.40 (Chapter 29, section 2: Perl Functions in Alphabetical Order).