More Named Pipes
October 11th, 2007
Regarding named pipes, Jayson asks “How is this any different than just redirecting the output from head to a file
and then using head to read the file again? Isn’t a text file fifo anyway?”
In some sense its no different than using a file. However named pipes are much much more than simply using a file to store output. Thanks goes to William for pointing out Greg’s BASH Faq where he eloquently explains:
“Named Pipes, also known as FIFOs (“First In First Out”) are well suited for inter-process communication. The advantage over using files as a means of communication is, that processes are synchronized by pipes: a process writing to a pipe blocks if there is no reader, and a process reading from a pipe blocks if there is no writer.“
He has a great example here. Named pipes are useful in some cases in shell programming. However, they are exceedingly useful when used in full fledged programming languages. Lets say you have a process that manages the execution of other processes. Starts and stops them as needed. You can use pipes to communicate with those processes. A great example is
using pipes to read and log the standard input/output of those processes.


Leave a Reply