my $g_pid = 0; sub AlarmHandler { kill 'KILL', $g_pid if $g_pid; $g_pid = 0; } local %SIG; $SIG{'ALRM'} = \&AlarmHandler; alarm ($Seconds); $g_pid = fork(); # blah, blah, blah alarm(0); # Turn off the timer