The C shell is not quite as sophisticated at handling signal
interruptions during script execution as the Bourne shell.
The C shell can handle signals in a very general way with the
By general it is meant that all signals are essentially handled the
same, which is unlike the way that trap works in the Bourne shell.
There are three ways in which to use the
ointr command within a
The first of these is simply
which will cause the script to terminate on any signal.
The second use of
works in the opposite manner by ignoring all signals, which might be
used to allow a script to clean up any files written during execution.
The third and last use of the
onintr command is
which sends the script to
LABEL to continue execution of
commands after that point.
Again, this could be used to remove any temporary files or write out
any last minute information to a file.
The execution of commands after
LABEL will continue until
exit command or the end of the script, so an
exit command should be placed after the desired commands.
The C shell has another way of handling signal interruptions caused by
turning off a terminal or disconnecting a line to a remote terminal.
nohup command (do not hangup) causes a command to continue
execution after a hangup.
Used on a command line
nohup has the following form:
The C shell provides an automatic
nohup in the sense that any
commands or programs run in the background using the (
next section) will not be killed by a hangup signal (
In a shell script,
nohup will cause the remainder of the script
to run to completion, ignoring the