Killing processes, and sending and responding to signals
You may need to kill processes (if they go rogue and start consuming too many resources) if you need to reduce system load, or before rebooting. Signals are an inter-process communication mechanism that interrupts a running process and forces it to perform some action. These actions include forcing a process to terminate in either a controlled or immediate manner.
Getting ready
Signals send an interrupt to a running program. When a process receives a signal, it responds by executing a signal handler. Compiled applications generate signals with the kill
system call. A signal can be generated from the command line (or shell script) with the kill
command. The trap
command can be used in a script to handle received signals.
Each signal is identified by a name and an integer value. The SIGKILL (9)
signal terminates a process immediately. The keystroke events Ctrl+ C and Ctrl + Z send signals to abort or put the task in the background.