next up previous contents
Next: Creating pipes in C Up: UNIX® Inter-process communication Previous: UNIX® Inter-process communication   Contents


Basic concepts

Simply put, a pipe is a method of connecting the standard output of one process to the standard input of another. The standard input and the standard output are virtual devices where the process writes or reads from by default (though the standard input and the standard output can be redirected to any device or any file).

Pipes are the oldest of the IPC tools, having been around since the earliest incarnations of the UNIX operating system. They provide a method of one-way communications (hence the term half-duplex) between processes. This feature is widely used, even on the UNIX command line (in the shell).

     ls | sort | lp

The above example sets up a pipeline, taking the output of ls as the input of sort, and the output of sort as the input of lp. The data is running through a half duplex pipe, traveling (visually) left to right through the pipeline. As it was mentioned the standard input (or the standard output) can be redirected to the given file instead of another process.

     ls | sort > ls.txt

The above example creates a pipeline between ls and sort, the standard output of ls is redirected as the standard input of sort, and then the standard output of sort is redirected to the file named ls.txt.


next up previous contents
Next: Creating pipes in C Up: UNIX® Inter-process communication Previous: UNIX® Inter-process communication   Contents
Igor Wojnicki 2001-02-21