$SIG{ALRM} = sub { die 'Timeout'; }; alarm( some decent duration ); eval { fork the child here wait for the child (waitpid() or similar) if the child returns reset the alarm (alarm(0)) }; if($@) { if($@ =~ /Timeout/) { # child exceeded authorized run time, so kill it kill(15, $child); } else { handle other fatal problems.... } }