FIFO(4) Linux Programmer's Manual FIFO(4)
NAME
fifo - first-in first-out special file(1,n), named(5,8) pipe(2,8)
DESCRIPTION
A FIFO special file(1,n) (a named(5,8) pipe(2,8)) is similar to a pipe(2,8), except that it
is accessed as part of the file(1,n) system. It can be opened by multiple
processes for reading or writing. When processes are exchanging data
via the FIFO, the kernel passes all data internally without writing it
to the file(1,n) system. Thus, the FIFO special file(1,n) has no contents on the
file(1,n) system, the file(1,n) system entry merely serves as a reference point
so that processes can access(2,5) the pipe(2,8) using a name in(1,8) the file(1,n) system.
The kernel maintains exactly one pipe(2,8) object for each FIFO special file(1,n)
that is opened by at least one process. The FIFO must be opened on
both ends (reading and writing) before data can be passed. Normally,
opening the FIFO blocks until the other end is opened also.
A process can open(2,3,n) a FIFO in(1,8) non-blocking mode. In this case, opening
for read(2,n,1 builtins) only will succeed even if(3,n) noone has opened on the write(1,2) side
yet; opening for write(1,2) only will fail with ENXIO (no such device or
address) unless the other end has already been opened.
Under Linux, opening a FIFO for read(2,n,1 builtins) and write(1,2) will succeed both in(1,8)
blocking and non-blocking mode. POSIX leaves this behaviour undefined.
This can be used to open(2,3,n) a FIFO for writing while there are no readers
available. A process that uses both ends of the connection in(1,8) order to
communicate with itself should be very careful to avoid deadlocks.
NOTES
When a process tries to write(1,2) to a FIFO that is not opened for read(2,n,1 builtins) on
the other side, the process is sent a SIGPIPE signal.
FIFO special files can be created by mkfifo(1,3)(3), and are specially indi-
cated in(1,8) ls -l.
SEE ALSO
mkfifo(1,3)(1), open(2,3,n)(2), pipe(2,8)(2), sigaction(2), signal(2,7)(2), socketpair(2),
mkfifo(1,3)(3)
Linux 1999-06-20 FIFO(4)