in reply to SIGALRM and Win32

What is your code? It works on 5.8.x
eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required alarm 2; # $nread = sysread SOCKET, $buffer, $size; sleep 4; alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; # propagate unexpected errors # timed out warn "alarm timed out"; } else { warn "success "; } __END__ alarm timed out at - line 11.

Replies are listed 'Best First'.
Re^2: SIGALRM and Win32
by Anonymous Monk on Mar 17, 2004 at 09:27 UTC
    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.