[Newbies] reading from named pipes

johnps11 at bigpond.com johnps11 at bigpond.com
Thu May 22 20:33:12 UTC 2008


> Hi there,
>
> I'm trying to read from a named pipe.  I'm on Linux (Ubuntu 8.04).
>
>    - I created the pipe using mkfifo
>    - I can write to it, and when I cat the pipe within another terminal I
>    see the output.
>    - I've tried using various combinations of FileStream,
>    OSProcess-ExternalPipe and OSProcess-AsyncFileReadStream.
>    - For example, I used this code:
> pipe := OSPipe new.
> file := FileStream fileNamed: '/my/named/pipe'.
> pipe reader: file.
> foo := pipe upToEndOfFile.
>       It just hangs when I do this.
>
> Any suggestions?

Unix named pipes block until processes have opened each end of the pipe. 
This is normal behaviour.  When you get the hung squeak, switch to another
term and try:

echo > /my/named/pipe
useless mindless text
^D

and  the string 'useless mindless text\n' should then be in foo.

John



More information about the Beginners mailing list