sub alarm my $child_pid = fork(); if ($child_pid) { wait; print "received alarm\n"; ... } else { sleep($seconds); }