The Bourne shell controls what the shell does when it gets an interrupt or signal (from the command, from a keyboard character like CTRL-c, and so on). To run an - like an editor or a simple command such as sort -the shell starts a (subprocess). If the program running in the child process wants to handle its own signals, the parent shell should probably pass signals on to the child process. For example, you might run vi as a child process and want to send a CTRL-c to stop vi from what it's doing, but not want the CTRL-c to kill the parent shell script.
When the parent process gets a signal, should it die or keep running? Should the child get the signal or not? The Bourne shell gives you a fair amount of flexibility in signal handling. The bad news is that most sh manual pages don't say much about this. And no manual page I've seen explains a useful choice: using the with trap . Table 45.1 shows your choices.
Because so much of this is undocumented, I won't try to give you "the answers" for how it should work with your shell. Instead, here are two shell scripts that let you experiment with your shell's signal handling. One script, named parent , starts the second script, child . The child script sets some traps, then startsso it'll be there when you send a signal. This lets you use CTRL-c or other interrupts, if parent is running in the foreground - or the kill command with signal numbers, if you've put parent in the background. You can edit the trap lines in the two scripts to test the setup you want to use.
Here's an example. I'll start parent in the background from the C shell, then send it a signal 1 ("hangup" signal):
Now, the scripts:
Even with this help, the way signal handling works might not be too clear. For more on signal handling, see a book that covers UNIX internals on your system.