4.5.6 Named pipes (FIFOs)
A named pipe is a file that acts like a pipe. You put something into the file,
and it comes out the other end. Thus it's called a FIFO, or
First-In-First-Out: the first thing you put in the pipe is the first thing to
come out the other end.
If you write to a named pipe, the process which is writing to the pipe doesn't
terminate until the information being written is read from the pipe. If you
read from a named pipe, the reading process waits until there's something to
read before terminating. The size of the pipe is always zero --- it doesn't
store data, it just links two processes like the shell |.
However, since this pipe has a name, the two processes don't have to be on the
same command line or even be run by the same user.
You can try it by doing the following:
$ cd; mkfifo mypipe
$ echo "hello" >mypipe & # put into background
[1] 5952
$ ls -l mypipe
prw-r--r-- 1 penguin penguin 0 2003-11-06 23:18 mypipe
$ cat mypipe
hello
[1]+ Done echo hello >mypipe
$ ls mypipe
prw-r--r-- 1 penguin penguin 0 2003-11-06 23:20 mypipe
$ rm mypipe