Every fork in the code is preceded by unless. unless (fork evaluating to undef()) is the only way any of the six branches can be followed and the only other possibility (pid=0) can't happen - it appears from your response you have projected your own ideas of intent and have lost the actual flow in that respect.