sysseek() does not work on a FIFO it seems.
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;
}
}
}