Coroutines clearly represent the most complex relationship between processes that the Korn shell defines. To conclude this chapter, we will look at a much simpler type of interprocess relationship: that of a shell subprocess with its parent shell. We saw in Chapter 3 that whenever you run a shell script, you actually invoke another copy of the shell that is a subprocess of the main, or parent, shell process. Now let’s look at them in more detail.
The most important things you need to know about shell subprocesses are what characteristics they get, or inherit, from their parents. These are as follows:
The current directory
Standard input, output, and error plus any other open file descriptors
Any characteristics defined in the environment file (see Chapter 3). Note that only interactive shells execute the environment file
Signals that are ignored
The first three characteristics are inherited by all subprocesses, while the last two are unique to shell subprocesses. Just as important are the things that a shell subprocess does not inherit from its parent:
Shell variables, except environment variables and those defined in the environment file
Handling of signals that are not ignored
We covered some of this earlier (in Chapter 3), but these points are common sources of confusion, so they bear repeating.
A special kind of shell subprocess is the subshell. The subshell is started ...