my $child_pid = fork(); if ($child_pid) { $ret = wait($child_pid, 1); do { ... #whatever you want; } until ($ret == -1); print "got alarm\n"; } else { sleep($seconds); }