Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: IO::Select and alarm()

by ikegami (Pope)
on Nov 01, 2011 at 19:56 UTC ( #935200=note: print w/ replies, xml ) Need Help??


in reply to Re^4: IO::Select and alarm()
in thread IO::Select and alarm()

Since my code DOES seems to work correctly,

$ perl -MIO::Select -E' my $sel = IO::Select->new(\*STDIN); $SIG{ALRM} = sub { }; alarm(1); while (my @ready = $sel->can_read()) { # ... } say "HERE"; ' HERE

The OP doesn't want to reach HERE, but apparently that's not a problem for you.


Comment on Re^5: IO::Select and alarm()
Download Code
Re^6: IO::Select and alarm()
by markseger (Beadle) on Nov 02, 2011 at 12:07 UTC
    ikegami: good example, but I'm not sure what you're trying to show me. Clearly the alarm is waking up the select but I already knew it does.

    I think the bigger question is when it wakes it up do you explicitly need to ignore the alarm inside the select loop? From my experiments, and if you put a print inside the loop, the code inside the loop doesn't execute (I assume this is because @ready is empty at this point), but I'm not sure whether this example is sufficient to prove it and think that is the key question, though it clearly operates as I've seen with my tests.

    -mark

      but I'm not sure what you're trying to show me.

      It shows the select loop being exited. As I said, the OP did not want to exit the select loop.

      I think the bigger question is when it wakes it up do you explicitly need to ignore the alarm inside the select loop?

      If you don't, the select loop is exited, so you're asking why there is a need to not exit the select loop.

      I don't believe there is such a universal need. Like I said, the OP has such a need, but apparently you don't.


      That said, I suspect you didn't actually show your entire select loop, and that you actually ignore *all* errors. If so, you would also be ignoring EINTR just like I told the OP to do.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://935200]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-09-16 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (157 votes), past polls