Signaling processes.
Signals
Signaling is the ability to communicate with a running process.
Generated by user from command line.
- Using [ctrl] characters such as [ctrl]c, [ctrl]z, etc.
- Using the kill command.
Generated by other processes.
man -s 7 signal
General actions by receiving process.
Term - terminate process.
[ctrl]c - interrupt - generates a Term type signal.
Ign - ignore signal.
Child process has stopped or terminated.
Socket needs attention.
Core - terminate with a core dump. (debugging)
See : man core
Stop - Stop - suspend process.
[ctr]z in the shell generates a Stop type signal.
Cont - continue a stopped process.
fg and bg generate a Cont type signal.
Not all signals are available to user at the command prompt.
Many, but not all, signals can be trapped.
Signal value between 1 and 64, about 31 defined.
Common signals
SIGHUP 1 kill -HUP Hang up, trappable.
If trapped, can signal program to re-read its configuration files.
SIGINT 2 [ctrl]c Interrupt, trappable.
If trapped, can allow program to try to shutdown gracefully.
SIGQUIT 3 [ctrl]\ Interrupt (core dump), trappable.
More useful for compiled programs.
SIGKILL 9 kill -KILL Untrappable, kill (terminate).
For when things have gone very wrong.
SIGTERM 15 kill Standard termination, trappable.
kill with no signal option, generates a 15.
SIGCONT 18 bg Restart a paused process, trappable.
fg generates a CONT.
SIGSTOP 19 kill -STOP Untrappable, suspend execution
SIGTSTP 20 [ctrl]z Suspend execution, trappable.
Use care. If you trap [ctrl]z,
you will have to log into another term to kill/suspend process.
Because the numeric value can vary for different versions of Linux/Unix,
It is considered better form to use the symbolic aliases when handling the
signals.
The include.h that has actual definitions for our 64-bit systems :
/usr/include/x86_64-linux-gnu/bits/signum.h