in reply to Perl Alarm Not Working

With Deferred (or Safe) Signals enabled--the default since 5.8.something--there are (many) somethings that cannot be interrupted by SIGALRM.

Reading your later description of do_program(), it seems like that it is doing many, maybe even most, of those somethings.

You may find the use of Perl::Unsafe::Signals worth testing.


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^2: Perl Alarm Not Working
by ikegami (Patriarch) on Dec 19, 2010 at 21:21 UTC
    The db code won't be interruptible* (a good thing), but the LWP stuff will be. No idea what "abstract the site page information" means, much less how it's implemented, so I don't know about that.

    * — That means the signal handler will be called when the db code returns if the signal was sent when the db code was executing.

      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.
        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". ;-)