System Interface Guide

Named Pipes

Named pipes function much like pipes, but are created as named entities in a file system. This allows the pipe to be opened by any processes with no requirement that they be related by forking. A named pipe is created by a call to mknod(2). Then any process with appropriate permission can read from or write to a named pipe.

In the open(2) call, the process opening the pipe blocks until another process also opens the pipe.

To open a named pipe without blocking, the O_NDELAY mask (found in <sys/fcntl.h>) can be or-ed with the selected file mode mask on the call to open(2). If no other process is connected to the pipe when open(2) is called, -1 is returned with errno set to EWOULDBLOCK.