Named pipe (FIFO special file)
A Unix named pipe is a filesystem-named FIFO special file that connects processes through a kernel-managed byte stream rather than stored file payload.
mkfifo() creates the filesystem entry with access permissions determined by the requested mode and applicable creation rules. The inode type is S_IFIFO, tested with S_ISFIFO(st_mode), distinct from regular files and character devices. This record covers Unix FIFO semantics, not the Windows named-pipe API. [1] [2] [6]
The pathname locates the channel; transmitted bytes are not saved as filesystem contents. Blocking read-only or write-only open normally waits for the opposite endpoint. With O_NONBLOCK, read-only open can succeed without a writer; write-only open fails with ENXIO without a reader. Linux permits O_RDWR opening, but POSIX leaves that behavior undefined. [3]
The stream has no message boundaries. Writes of at most PIPE_BUF bytes avoid interleaving with other writers; PIPE_BUF is not the pipe capacity. For nonblocking writes within that limit, insufficient space yields EAGAIN instead of a partial write. Larger writes can interleave. These rules provide neither one read per write nor durable storage. [4] F_GETPIPE_SZ reports nominal capacity; page-buffer layout and write sizes can reduce the bytes actually writable. [7]
After queued bytes are consumed, a positive-length read returns zero when all write-end descriptors are closed. Writing with no read-end descriptors generates SIGPIPE; if ignored, the operation fails with EPIPE. Retained duplicate endpoint descriptors therefore affect termination detection. A zero-length read is not an EOF test. [4] [5]
Relations
- related
- Inode, Regular file
Citations
- Linux man-pages: mkfifo(3), creation and permissions
- Linux man-pages: inode(7), FIFO file type
- Linux man-pages: fifo(7), pathname and open semantics
- Linux man-pages: pipe(7), capacity, atomic writes and endpoint lifetime
- Linux man-pages: read(2), zero-length requests and return values
- Linux man-pages: acl(5), object creation and default ACL inheritance
- Linux man-pages: F_GETPIPE_SZ(2const), nominal capacity and usable buffer space
Sources & caveats
- Primary-source terminology synthesis; no new IPC experiment, capacity measurement or persistence test was performed.