in reply to How to make sysread timeout

The alarm documentation contains an example of how to use it to timeout sysread specifically.

Replies are listed 'Best First'.
Re^2: How to make sysread timeout
by redss (Monk) on Nov 01, 2007 at 19:35 UTC
    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; };

      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?