in reply to Re^2: Perl Alarm Not Working
in thread Perl Alarm Not Working

the LWP stuff will be [interuptable]

You sure?

When I run the following two one liners, 'here' is printed after 30 seconds--when the server times out--not after 10 as it would be if the alarm had interupted the socket read.

C:\test>start /b perl -MIO::Socket -E"$s=IO::Socket::INET->new(Listen=>1,LocalPort=>12345);$c=$s->accept; +sleep 30" C:\test>perl -MIO::Socket -E"$s=IO::Socket::INET->new('localhost:12345');eval{alarm 10;<$s>};pri +nt'here'" here

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Perl Alarm Not Working
by afoken (Chancellor) on Dec 19, 2010 at 22:16 UTC
    C:\test>start /b perl -MIO::Socket -E"$s=IO::Socket::INET->new(Listen=>1,LocalPort=>12345);$c=$s->accept; +sleep 30" C:\test>perl -MIO::Socket -E"$s=IO::Socket::INET->new('localhost:12345');eval{alarm 10;<$s>};pri +nt'here'" here

    Windows has no signals. Not even SIGALRM. Perl emulates them, and the emulation is far from perfection. (It's actually pretty good, given that ugly Windows API.)

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      You're telling me non-useful information I already know. alarm does interupt non-io operations on windows:

      C:\test>perl -E"$c=0;eval{ alarm 10; ++$c while 1; alarm 0;}" Terminating on signal SIGALRM(14)

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        You're telling me non-useful information I already know.

        No, apparently you don't.

        $ perl -MIO::Socket -E'$s=IO::Socket::INET->new(Listen=>1,LocalPort=>1 +2345);$c=$s->accept; sleep 30' & [1] 3863 $ perl -MIO::Socket -E'$s=IO::Socket::INET->new("localhost:12345");eva +l{alarm 10;<$s>};print"here"' Alarm clock

        alarm does interupt non-io operations on windows:

        No, just some. The coverage isn't complete.