in reply to Non-blocking I/O woes

The $select->can_read() does not block, despite what documentation says. It keeps reporting that there's something in STDIN

Have you considered simplifying your code by using an event-loop system? For instance, can you use a simple program like this?

#!/usr/bin/perl use warnings; use strict; use Glib; my $main_loop = Glib::MainLoop->new; Glib::IO->add_watch (fileno 'STDIN', [qw/in/], \&watch_callback, 'STDI +N'); #just to show it's non blocking my $timer1 = Glib::Timeout->add (1000, \&testcallback, undef, 1 ); $main_loop->run; sub watch_callback { # print "@_\n"; my ($fd, $condition, $fh) = @_; my $line = readline STDIN; print $line; #always return TRUE to continue the callback return 1; } sub testcallback{ print "\t\t\t".time."\n"; } __END__
POE is another eventloop alternative with an nice POE Cookbook See the section on ProcessManagement


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Non-blocking I/O woes
by dwalin (Monk) on Jan 10, 2011 at 19:14 UTC
    Thanks for advice, I'll consider using it as last resort. I need to avoid any extra modules and/or software on that box since that'd break vendor maintenance conditions and you know how anal they're going to be about that. Even more, if I can make this script work it'll probably run on scores of customers' boxes, making maintenance headaches unbearable...