| 1 |
.\" Copyright 1999, Claus Fischer |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-1-para |
| 5 |
.\" |
| 6 |
.TH fifo 7 2026-02-08 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
fifo \- first-in first-out special file, named pipe |
| 9 |
.SH DESCRIPTION |
| 10 |
A FIFO special file (a named pipe) is similar to a pipe, |
| 11 |
except that it is accessed as part of the filesystem. |
| 12 |
It can be opened by multiple processes for reading or |
| 13 |
writing. |
| 14 |
When processes are exchanging data via the FIFO, |
| 15 |
the kernel passes all data internally without writing it |
| 16 |
to the filesystem. |
| 17 |
Thus, |
| 18 |
the FIFO special file has no contents on the filesystem; |
| 19 |
the filesystem entry merely serves as a reference point |
| 20 |
so that processes can access the pipe |
| 21 |
using a name in the filesystem. |
| 22 |
.P |
| 23 |
The kernel maintains exactly one pipe object for each |
| 24 |
FIFO special file that is opened by at least one process. |
| 25 |
The FIFO must be opened on both ends (reading and writing) |
| 26 |
before data can be passed. |
| 27 |
Normally, |
| 28 |
opening the FIFO blocks |
| 29 |
until the other end is opened also. |
| 30 |
.P |
| 31 |
A process can open a FIFO in nonblocking mode. |
| 32 |
In this case, |
| 33 |
opening for read-only succeeds |
| 34 |
even if no one has opened on the write side yet |
| 35 |
and opening for write-only fails with |
| 36 |
.B ENXIO |
| 37 |
(no such device or address) |
| 38 |
unless the other end has already been opened. |
| 39 |
.P |
| 40 |
Under Linux, |
| 41 |
opening a FIFO for read and write will succeed |
| 42 |
both in blocking and nonblocking mode. |
| 43 |
POSIX leaves this behavior undefined. |
| 44 |
This can be used to open a FIFO for writing |
| 45 |
while there are no readers available. |
| 46 |
A process that uses both ends of the connection |
| 47 |
in order to communicate with itself |
| 48 |
should be very careful to avoid deadlocks. |
| 49 |
.SH NOTES |
| 50 |
For details of the semantics of I/O on FIFOs, see |
| 51 |
.BR pipe (7). |
| 52 |
.P |
| 53 |
When a process tries to write to a FIFO |
| 54 |
that is not opened for read on the other side, |
| 55 |
the process is sent a |
| 56 |
.B SIGPIPE |
| 57 |
signal. |
| 58 |
.P |
| 59 |
FIFO special files can be created by |
| 60 |
.BR mkfifo (3), |
| 61 |
and are indicated by |
| 62 |
.I ls\~\-l |
| 63 |
with the file type \[aq]p\[aq]. |
| 64 |
.SH SEE ALSO |
| 65 |
.BR mkfifo (1), |
| 66 |
.BR open (2), |
| 67 |
.BR pipe (2), |
| 68 |
.BR sigaction (2), |
| 69 |
.BR signal (2), |
| 70 |
.BR socketpair (2), |
| 71 |
.BR mkfifo (3), |
| 72 |
.BR pipe (7) |