in reply to Re^2: forking and timeouts
in thread forking and timeouts
No it's the other way round. It will always be 0 in the child process, and the PID of the child process in the parent.
To show it a bit clearer perhaps:
$pid = fork(); if (!defined $pid) { print "Fork failed: $@"; } elsif ($pid) { print "I am the parent, my PID is $$ and my child's PID is $pid\n"; } else { print "I am the child, my PID is $$ and my parent's PID is " . getpp +id() . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: forking and timeouts
by Earindil (Beadle) on Aug 09, 2007 at 16:10 UTC |