in reply to Re: How to make sysread timeout
in thread How to make sysread timeout

That alarm documentation gives a clear example, but it isn't working. Shouldn't the below code timeout every second?
eval { $timeout = 1; local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; $ret = sysread($sock, $buf, 100); alarm 0; };

Replies are listed 'Best First'.
Re^3: How to make sysread timeout
by kyle (Abbot) on Nov 01, 2007 at 19:59 UTC

    What platform are you on (you haven't specified)? Windows in particular is not so good with signals. In that case, you might need to look at Re: Backticks and SIGALRM.

      I'm on windows XP. There's no way to get that example to work on windows?
        As suggested above, use IO::Select. It's a much more flexible approach. There's a tutorial here.

        -David