These 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.
The reason for handling these signals is usually so your program can tidy up as appropriate before actually terminating. For example, you might want to save state information, delete temporary files, or restore the previous terminal modes. Such a handler should end by specifying the default action for the signal that happened and then reraising it; this will cause the program to terminate with that signal, as if it had not had a handler. (See section Handlers That Terminate the Process.)
The (obvious) default action for all of these signals is to cause the process to terminate.
SIGTERMsignal 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
SIGTERM by default.
SIGINT("program interrupt") signal is sent when the user types the INTR character (normally C-c). See section Special Characters, for information about terminal driver support for C-c.
SIGQUITsignal is similar to
SIGINT, except that it's controlled by a different key--the QUIT character, usually C-\---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.
See section Program Error Signals, for information about core dumps. See section Special Characters, for information about terminal driver support.
Certain kinds of cleanups are best omitted in handling
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.
SIGKILLsignal 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.
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 C-c or
If a process does not respond to any other termination signals, sending
SIGKILL signal will almost always cause it to go away.
In fact, if
SIGKILL fails to terminate a process, that by itself
constitutes an operating system bug which you should report.
The system will generate
SIGKILL for a process itself under some
unusual conditions where the program cannot possible continue to run
(even to run a signal handler).
SIGHUP("hang-up") signal is used to report that the user's terminal is disconnected, perhaps because a network or telephone connection was broken. For more information about this, see section Control Modes.
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 section Termination Internals.
Go to the first, previous, next, last section, table of contents.