[TriLUG] confessions of a bash junky: the mkfifo command

James Olin Oden james.oden at gmail.com
Tue Aug 28 13:22:25 EDT 2007


On 8/28/07, Brian McCullough <bdmc at bdmcc-us.com> wrote:
> On Tue, Aug 28, 2007 at 11:14:38AM -0400, jonc at nc.rr.com wrote:
> > I write a lot of scripts. I mean a LOT of scripts. If I can solve a problem in 10 to 15 minutes by throwing it into a bash script, then that's what happens. So I *love* bash... unabashedly.
>
>
> ( Groan )
>
>
> > # Note: the script stays frozen here till the pipe is cleared
> > #
> > # Another process runs and pulls from the pipe
> > #
> > # Note2: you can grab from the pipe first - which causes that script
> > #   to wait for input. Then when the first script runs and loads the buffer
>
>
> Yup.  This is an OLD UNIX trick ( tool, whatever ) used for interprocess
> communication both internally and at the command line.  ( That's what
> implements the "|" in any shell in any of the UN*X-alikes. )
>
>
Not sure about that last statement.  What he is creating is a named
pipe (init uses this on most linuxes to take commands and transfer its
state when it re-execs itself).  Named pipes are created in C with the
mknod() call, whereas the | operator in shell is creating an unnamed
pipe (i.e. one without any ties to a filesystem), and that  is created
with the pipe() call in C (to read these man pages do:  man 2 pipe or
man 2 mknod).

So, the better way of looking at the named pipes is they are simply a
pipe with a link in the filesystem thus providing access via the
filesystem.

Cheers...james



More information about the TriLUG mailing list