I think it's because you are intermixing
sleep and
alarm. Some platforms implement alarm using sleep (or something like that - some tidbit of info I picked up somewhere), so mixing those two together is not good. If you replace your
sleep 4; line with
select(undef,undef,undef,4); or
my $foo = <STDIN>;, it will not work -- you get a success with the select() version and the script 'hangs' waiting for input with the STDIN version (on my system anyhow). Just as if the signal was never received.