Fork splits the current process into two when it is executed. Both processes continue executing right after the fork call.
The only* difference between the two resulting processes is that in one (the parent), fork()
returns the child's PID, while in the other (the child), fork()
returns zero.
So in the parent, the $childProcessID
is non-zero and the if
branch is taken, while in the child that variable is zero and the else
branch is executed.
* Probable not really pedantically true.