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"; }
In reply to Re^3: forking and timeouts
by Crackers2
in thread forking and timeouts
by Earindil
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |