Open a terminal, type ls and press Enter. A list of files appears, the prompt comes back, and the whole thing takes a fraction of a second. In that fraction of a second a small drama played out. The shell, which is itself a running program, made a brand-new process. That process loaded the ls program, printed your files and ended. And the shell, which had been waiting patiently, noticed that its child was finished and gave you the prompt back. Every command you have typed on Linux, and every program a server starts at midnight, came to life this way.
The drama raises questions. Who creates a process, and what exactly does it copy? What if the child finishes and nobody asks how it went? What if the parent leaves first? And how do the programs that start at boot and never show a window, the printing service or the keeper of nightly jobs, come to exist at all? Once processes exist, there is a second puzzle: each lives in its own protected memory, so how do two of them ever pass a number, a message or a "please stop" to each other?
By the end of this chapter you will be able to write and trace the four calls that give a process its life (fork, exec, wait and exit), and say how many processes a small program leaves behind and how many lines it prints. You will explain a zombie, an orphan and a daemon. You will compare the two ways processes talk, shared memory and message passing, and explain a pipe, a signal, a message queue, a socket and a remote procedure call. Each of these you will have seen on a real machine.