6. Basic Interprocess Communication

6.1 Introduction

Now that we know how to create processes, we want to connect them so they can communicate. We’ll do this with pipes in this chapter, using basic techniques that have always worked on all versions of UNIX. In the next chapter we’ll start exploring interprocess communication using techniques that are more efficient and robust, less universally available, and more troublesome to program.

Pipes are familiar to most UNIX users as a shell facility. For instance, to display a sorted list of who’s logged in, you can type:

$ who | sort | more

There are three processes here, connected with two pipes. Data flows in one direction only, from who to sort to more. It’s also possible to set up pipelines ...

Get Advanced UNIX Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.