This preview shows page 1. Sign up to view the full content.
Unformatted text preview: command returns 0, then the shell creates a child process and executes the requested program inside the child. If the user has asked for the program to run in the background, then the shell returns to the top of the loop and waits for the next command line. Otherwise the shell uses the waitpid function to wait for the job to terminate. When the job terminates, the shell goes on to the next iteration. Notice that this simple shell is ﬂawed because it does not reap any of its background children. Correcting this ﬂaw requires the use of signals, which we describe in the next section. 8.5 Signals
To this point in our study of exceptional control ﬂow, we have seen how hardware and software cooperate to provide the fundamental low-level exception mechanism. We have also seen how the operating system uses exceptions to support a higher-level form of exceptional control ﬂow known as the context switch. In this section we will study a higher-level software form of exception, known as a Unix signal, that a...
View Full Document