in reply to Re: select($rin,undef,undef,undef) only blocking once
in thread select($rin,undef,undef,undef) only blocking once
sysseek() does not work on a FIFO it seems.
would it be a solution to reopen the FIFO before the select statement ?
it works, but i dont think that is the proper way....
would it be a solution to reopen the FIFO before the select statement ?
it works, but i dont think that is the proper way....
use strict; use POSIX qw(mkfifo); use Fcntl qw(O_RDONLY O_NONBLOCK SEEK_SET); use IO::Handle; my $fifofile = "fifo"; my $inputbuf; unlink($fifofile); mkfifo($fifofile, 0666) or die (' can\'t create FIFO:'.$fifofile); while (1){ sysopen(FIFOFD, $fifofile, O_RDONLY | O_NONBLOCK ) or die ("can\'t + read FIFO:'.$fifofile"); my $rin =''; vec($rin,fileno(FIFOFD),1)=1; select( $rin, undef, undef, undef ); print "select returning\n"; my $fromfifo; while ( sysread(FIFOFD, $fromfifo, 1) == 1 ){ $inputbuf .= $fromfifo ; } my $command; my $index; while ( $index = index($inputbuf,"\n" )+1 ){ my $command = substr($inputbuf,0,$index,""); if ( defined ($command) ) { print $command; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: select($rin,undef,undef,undef) only blocking once
by Tanalis (Curate) on Jul 26, 2005 at 12:09 UTC | |
by rabbit7 (Initiate) on Jul 26, 2005 at 13:43 UTC | |
by Tanalis (Curate) on Jul 26, 2005 at 13:49 UTC | |
by rabbit7 (Initiate) on Jul 27, 2005 at 11:13 UTC |
In Section
Seekers of Perl Wisdom