Lesson 17: Pipes and FIFO — IPC Between Processes
A pipe is a one-way communication mechanism between processes — what one writes, the other reads. Every shell pipeline (cmd1 | cmd2 | cmd3) is built from anonymous pipes. A FIFO (named pipe) extends the idea to unrelated processes. At NVIDIA, multi-process GPU inference pipelines pass work tokens be
A pipe is like a water pipe: one process pours water (writes), another draws it (reads). Water flows only one way and you can only draw what was poured.
- pipe
- A kernel-maintained one-way IPC buffer — one process writes to it, another reads from it. Created with pipe(fds) which returns a pair of FDs: fds[0]=read, fds[1]=write.
- FIFO (named pipe)
- A pipe with a name in the filesystem. Created with mkfifo(path, mode). Allows unrelated processes (not fork-related) to communicate via a filesystem entry.
- anonymous pipe
- A pipe without a filesystem name — can only be used between a parent process and its fork descendants (which inherited the FDs via fork). This is the pipe powering shell pipelines.
- named pipe
- Another name for FIFO — a pipe that can be opened by name like a regular file. Data flows through the kernel and is not stored on disk, even though there is a directory entry.
- half-close
- Closing only one end of a pipe FD pair. When all write ends are closed, reading from the read end returns 0 (EOF). Essential for correct fork+pipe communication.