[Gambas-user] PIPE issues

Benoît Minisini gambas at ...1...
Mon Dec 13 06:55:31 CET 2010


> Gambas2 2.21 rev3300
> 
> this example is not working in Ubuntu 10.04 AMD64
> 
> PUBLIC SUB Main()
> 
> ' Prints the messages sent to a pipe
> 
> DIM hFile AS File
> DIM sLine AS String
> 
> hFile = PIPE "/tmp/FIFO1" FOR INPUT
> 
> WHILE NOT Eof(hFile)
>   LINE INPUT #hFile, sLine
>   PRINT sLine
> WEND
> 
> END
> 
> The pipe is created ok!
> But if i make a ls > /tmp/FIFO1
> 
> nothing is appeared in console and program terminates.
> 

This is a pipe. Data is available only when it has been filled by the other 
side. So Eof() can returns true at anytime, even if some data may be written 
in the future. Gambas cannot read the future yet.

> if i change to
> WHILE TRUE
> 
> i get the ls results to console and
> i get an error
> 
> System error. Inappropriate ioctl for device.

The error message is not very accurate. But it is normal, as reading on a pipe 
that has been closed on the other side is impossible.

Regards,

-- 
Benoît Minisini




More information about the User mailing list