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 (Chaplain)
on Feb 01, 2005 at 22:30 UTC ( [id://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.

Replies are listed 'Best First'.
Re^2: What makes IO::Select::can_read return?
by sleepingsquirrel (Chaplain) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://427079]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-29 11:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found