[Gambas-user] Pipe doesn't receive contents

Benoît Minisini gambas at ...1...
Sat May 8 01:05:36 CEST 2010


> > > Trying the example code for pipes, I only get a waiting prompt, and
> > > then it jumps out of the loop.
> > > 
> > > I added two little statements to have some output:
> > > 
> > > DIM hFile AS File
> > > DIM sLine AS String
> > > 
> > > hFile = PIPE "/tmp/FIFO1" FOR INPUT
> > > 
> > > PRINT "Now let's start:"
> > > 
> > > WHILE NOT Eof(hFile)
> > > 
> > >    LINE INPUT #hFile, sLine
> > >    PRINT sLine
> > > 
> > > WEND
> > > 
> > > PRINT "That's it."
> > > 
> > > When I start this, it prints the start message and waits. It's in a
> > > Konsole window within KDE. I open another terminal and type
> > > 
> > > ls > /tmp/FIFO1
> > > 
> > > Instead of giving the file list, it just prints the finish message and
> > > quits.
> > > 
> > > Did I do something wrong?
> > > 
> > > Rolf
> > 
> > I just tried, and it works with "ls -la > /tmp/FIFO1", but not with "ls >
> > /tmp/FIFO1", as you described. Very strange...
> 
> It is actually random: sometimes it works as expected, sometimes Eof(hFile)
> returns True the first time it is called, and the pipe is not read. Very
> strange yet!

OK, I'm stupid. It's just silly to use Eof() with a pipe, because it just tell 
you that the pipe is void, and can't know that some data may come in the 
future. So if the program is too fast for the data to come, the first Eof() 
returns TRUE.

Regards,

-- 
Benoît Minisini




More information about the User mailing list