in reply to Perl Timers and command-line processes

Something like the following might work (untested, caveat emptor):
#!/usr/bin/perl -w use strict; use POSIX qw(:sys_wait_h); my $TIMEOUT=180;# or whatever my $start=time; if (my $pid = fork) { #parent while (1) { if (waitpid($pid,WNOHANG) == -1) { # child is done exit; } if ( time > ($start + $TIMEOUT)) { # time has expired, kill the child # this is probably too simplistic, # as the child could ignore the SIGTERM kill(15,$pid); exit; } sleep(1);# avoid the tight loop } } else { # child exec('/some/program'); }