# If fork returns 0, the current process is the child and not the parent. # If an error occurs, fork returns a special undefined value called undef. $pid = fork(); if ($pid == 0) { # We're in the child process. } elsif (! defined $pid) { # Not defined: means an error. } else { # Parent process. }