Frequently Asked Question
What is a named pipe (FIFO) and when would I use mkfifo?
An ordinary | pipe only exists for the lifetime of the two commands sharing it,
and only those two processes can use it. A named pipe, or FIFO, is a pipe that
lives in the filesystem with a real path. You create one with mkfifo /tmp/myfifo, and from then on any two processes, possibly started minutes
apart, possibly run by different users, can connect to it: one process writes
to the FIFO file, another reads from it, and the kernel buffers between them
exactly as with an anonymous pipe.
FIFOs are useful when you can't put the producer and consumer on the same command line. Classic uses include sending the output of a long-running background job to a log viewer in another terminal, building simple message queues between cooperating shell scripts, or wiring up an interactive tool that can't be replaced (like a database REPL) to a script that drives it. They share the same flow-control and SIGPIPE semantics as anonymous pipes; the only difference is the name.