Chapter 8. Process Handling

The UNIX operating system built its reputation on a small number of concepts, all of which are simple yet powerful. We’ve seen most of them by now: standard input/output, pipes, text-filtering utilities, the tree-structured file system, and so on. UNIX also gained notoriety as the first small-computer operating system to give each user control over more than one process. We call this capability user-controlled multitasking.

You may not think that multitasking is a big deal. You’re probably used to the idea of running a process in the background by putting an ampersand (&) at the end of the command line. You have also seen the idea of a subshell in Chapter 4, when we showed how shell scripts run.

In this chapter, we will cover most of bash’s features that relate to multitasking and process handling in general. We say “most” because some of these features are, like the file descriptors we saw in the previous chapter, of interest only to low-level systems programmers.

We’ll start out by looking at certain important primitives for identifying processes and for controlling them during login sessions and within shell scripts. Then we will move out to a higher-level perspective, looking at ways to get processes to communicate with each other. We’ll look in more detail at concepts we’ve already seen, like pipes and subshells.

Don’t worry about getting bogged down in low-level technical details about UNIX. We will provide only the technical information that is necessary ...

Get Learning the bash Shell, 3rd 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.