Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2008-02-17 21:33:12
Size: 801
Editor: 80-195-170-174
Comment: Initial import from Mark Hobley's Shell Programming Wiki
Revision 5 as of 2009-02-18 16:12:32
Size: 900
Editor: GreyCat
Comment: categories
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
The following is an example on how to create a named pipe, named here as pipe1. The following is an example on how to create a named pipe, named here as `pipe1`.
Line 7: Line 7:
{{{
Line 9: Line 10:
}}}
Line 12: Line 14:
{{{
Line 13: Line 16:
}}}
Line 14: Line 18:
The process will appear to be hung at this point. There is no other process running to collect the data, so the kernel suspends the process. The process is said to be "blocked" at this stage. (["No Waiting for a fifo process"]) The process will appear to be hung at this point. There is no other process running to collect the data, so the kernel suspends the process. The process is said to be "blocked" at this stage.
Line 18: Line 22:
 cat < pipe1 {{{
cat < /tmp/pipe1
}}}
Line 20: Line 26:
The data from the pipe will now be received, and the "blocked" process will be free to resume. The data from the pipe will now be read by `cat` (and written to the terminal), and the "blocked" writer process will be free to resume.

For some more information, see [[BashFAQ/085|Bash FAQ #85]].
Line 23: Line 31:

["Atomic Writes to Named Pipes"]
CategoryShell CategoryUnix

Working with Named Pipes

Pipes allow processes to to communicate with each other. A pipe may also be known as a "FIFO" (First In, First Out).

The following is an example on how to create a named pipe, named here as pipe1.

 cd /tmp
 mkfifo pipe1

To send a message to the pipe, use:

 echo "hello" > pipe1

The process will appear to be hung at this point. There is no other process running to collect the data, so the kernel suspends the process. The process is said to be "blocked" at this stage.

On another terminal, it is possible to collect the data from the pipe, as follows:

 cat < /tmp/pipe1

The data from the pipe will now be read by cat (and written to the terminal), and the "blocked" writer process will be free to resume.

For some more information, see Bash FAQ #85.


CategoryShell CategoryUnix

NamedPipes (last edited 2012-07-21 09:01:02 by 77)