in reply to Non-blocking I/O woes
Have you considered simplifying your code by using an event-loop system? For instance, can you use a simple program like this?
POE is another eventloop alternative with an nice POE Cookbook See the section on ProcessManagement#!/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__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Non-blocking I/O woes
by dwalin (Monk) on Jan 10, 2011 at 19:14 UTC |