$pid=fork; if ($pid==0) {try and start new process with exec??} elsif ($pid) {do what I want to do with this script??} else {die because of fork error } #### use warnings; $pid = fork; if (!defined($pid)) { die "fork error"; } elsif (!$pid) { #line 6 "child" warn "starting"; for (1 .. 5) { sleep 1; warn "working hard. really. ", $_*20, "%"; } exit; # or exec } else { #line 14 "parent" warn "starting the parent"; for (1 .. 2) { sleep 1; warn "doing some work"; } warn "waiting for the child to finish (or just collecting it if it has finished"; $pid == waitpid($pid, 0) or die "error waiting: $!"; 0 == $? or die "child has died"; warn "ok, collected the child successfully"; } __END__