Hi.
Unix
signal is a kind of event sent asynchronously to your program by other programs.
trap allows you to declare signal handler. For example your script may create some temporary files which should be deleted when script exits. But if user press Ctrl+C, thus sending SIGINT signal to your program, the program exits immediately, leaving a mess of temporary files on the disk. To handle SIGINT signal:
Code:
trap 'rm $TEMPFILE' INT
Some signals, like USR1, USR2, are often used to reload configuration files without stopping the program.
Signals may be sent using the
kill utility.
See
man 1 kill,
help trap,
man -k kill for details.
Hope that helps.