use POSIX ":sys_wait_h"; my $child = fork; if ($child) { # parent case my $res; while (not ($res = waitpid($child, WNOHANG))) { sleep 5; # check file list here # ... } if ($res == -1) { warn "fatal child error\n"; exit; } } else { # child case # insert job processing here exit; # child must explicitly exit otherwise both would continue executing this } # reach here if job processing completed successfully