while ($pid = fork()) { if ($pid) { print "$pid\n"; #returns nonzero in the parent } else { print "$pid\n"; #returns zero in the child } }