Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: What makes IO::Select::can_read return?

by sleepingsquirrel (Hermit)
on Feb 01, 2005 at 22:30 UTC ( #427079=note: print w/ replies, xml ) Need Help??


in reply to What makes IO::Select::can_read return?

One possibility, (from the man page for the select system call)...

Any signal will cause select to return immediately. So if your program uses signals, you can't rely on select to keep waiting for the full time specified. If you want to be sure of waiting for a particular amount of time, you must check for EINTR and repeat the select with a newly calculated timeout based on the current time. See the example below.

I don't really know how Perl ends up wrapping the underlying system call. Might be something to check into.


-- All code is 100% tested and functional unless otherwise noted.


Comment on Re: What makes IO::Select::can_read return?
Re^2: What makes IO::Select::can_read return?
by sleepingsquirrel (Hermit) on Feb 01, 2005 at 23:16 UTC
    Run the program below and do a kill -USR1, to see it in action.
    #!/usr/bin/perl -w use IO::Select; my $sel = new IO::Select (\*STDIN); $SIG{USR1} = sub { print "signal\n"}; if (my @socks = $sel->can_read(50)) { warn "Got Here\n"; } else { warn "Else: $!\n"; }


    -- All code is 100% tested and functional unless otherwise noted.
Re^2: What makes IO::Select::can_read return?
by beemshake (Novice) on Feb 02, 2005 at 17:19 UTC
    You guys rule. Yeah, I was getting a SIGCHLD when I thought all my child processes were already cleaned up. Just had to stick a print in the sig handler to catch it. Thanks monks!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (21)
As of 2014-08-20 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (122 votes), past polls