my $pid = fork(); die "failed to fork" unless defined $pid; if ($pid) { # we are parent. do things } else { # we are child. do other things }