[Gambas-user] Pipe doesn't receive contents

Doriano Blengino doriano.blengino at ...1909...
Fri May 7 19:59:03 CEST 2010


Rolf Schmidt ha scritto:
> Hi Doriano
>
>    
>>> You can't wait until EOF on a named pipe! Also a 'tail' on a named pipe
>>> will never give you some data - but 'cat' do!
>>>
>>> Just read and find another mechanism to stop reading.
>>>        
>> I tried cat and tail on named fifo, and both work. You can start first
>> either of the two sides, and they work.
>> I did it with:
>>
>> mkfifo /tmp/fifo
>> ls>/tmp/fifo
>>      
> ls sends a termiated data stream!
>    
>> then, in another terminal:
>>
>> tail -3 /tmp/fifo
>>      
> Of course you can read it, because ls stops when the content is in the pipe.
>
>    
>> I also tried to start first the tail command, and then the cat>...
>>
>>      
> See a server which sends data via named pipe, then you will recognice,
> that 'cat' can show the data while 'tail' waits for an end of file, which
> will only come when the server stops!
>
> Hope it becomes more clear.
>    
Yes, it is clear, perhaps more for me than for you...

Our friend Rolf-Werner tried to read a fifo from gambas. The outputting 
source was an "ls >...":

    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.


This is exactly the same thing I tried after you said that FIFOs don't 
carry any EOF.
It works - so FIFOs do carry EOF - in fact, I already use them in real 
world, but I didn't want to say it.

You are saying another thing: if the server does not close its 
outputting channel, then the FIFO will not transmit an EOF. Clearly, a 
FIFO can not invent non-existent EOFs! In fact, I tried:

     mkfifo /tmp/fifo
     cat /tmp/fifo

then, in another terminal:

     cat > /tmp/fifo

At this point, *both* the programs wait until I terminate one of them; 
unsing tail(1) gives the expected results: it hangs waiting for an eof 
from the source - if you don't terminate the outputting source, this eof 
will never come.

Now, for me everything is clear - is it clear for you too? :-)
Perhaps you are referring to other problems, at kernel level, but this 
is a very simple situation.

Regards,
Doriano





More information about the User mailing list