UNIX Termination Signals


The UNIX termination signals are all used to tell a process to terminate, in one way or another. They have different names because they’re used for slightly different purposes, and programs might want to handle them differently. One must understand the intricacies amongst the different signals to understand the correct way to get out of a process. Another way to look at this would be to be able to save state information, delete temporary files, or restore the previous terminal modes.

SIGTERM
The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL, this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to terminate.
The shell command kill generates SIGTERM by default. 

SIGINT [control+c]
The SIGINT (“program interrupt”) signal is sent when the user types the INTR character (normally control+c).

SIGQUIT [control+\]
The SIGQUIT signal is similar to SIGINT, except that it’s controlled by a different key—the QUIT character, usually control+\ —and produces a core dump when it terminates the process, just like a program error signal. You can think of this as a program error condition “detected” by the user.
Certain kinds of cleanups are best omitted in handling SIGQUIT. For example, if the program creates temporary files, it should handle the other termination requests by deleting the temporary files. But it is better for SIGQUIT not to delete them, so that the user can examine them in conjunction with the core dump.

SIGKILL [kill -9]
The SIGKILL signal is used to cause immediate program termination. It cannot be handled or ignored, and is therefore always fatal. It is also not possible to block this signal. The "kill -9" command in Linux generates the same signal.
This signal is usually generated only by explicit request. Since it cannot be handled, you should generate it only as a last resort, after first trying a less drastic method such as control+c or SIGTERM. If a process does not respond to any other termination signals, sending it a SIGKILL signal will almost always cause it to go away.

SIGHUP [control+d]
The SIGHUP (“hang-up”) signal is used to report that the user’s terminal is disconnected, perhaps because a network or telephone connection was broken.
This signal is also used to report the termination of the controlling process on a terminal to jobs associated with that session; this termination effectively disconnects all processes in the session from the controlling terminal. For more information, see Termination Internals.