in reply to killing a process after some time

Here is an example from alarm in the perlfunc manpage:

eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm $timeout; $nread = sysread SOCKET, $buffer, $size; alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out } else { # didn't } __END__

You could probably adapt this to do what you need.

Update: Link fixed.