I was updating the kill command page earlier today and realised that it could have more information about the signals available for requesting Unix process to terminate. It seems there's enough information for a blog post, and I'll link to it from the kill command page.
How To Get Full List of Process Signals
This is a low level enough element of Unix functionality, so you'll need to look at one of the OS headers (part of its source code) – /usr/include/asm/signal.h is usually the name of signals file in Linux:
greys@s2:/ $ more /usr/include/asm/signal.h #ifndef _ASM_X86_SIGNAL_H #define _ASM_X86_SIGNAL_H #ifndef __ASSEMBLY__ #include <linux/types.h> #include <linux/time.h> /* Avoid too many header ordering problems. */ struct siginfo; /* Here we must cater to libcs that poke about in kernel headers. */ #define NSIG 32 typedef unsigned long sigset_t; #endif /* __ASSEMBLY__ */ #define SIGHUP 1 #define SIGINT 2 #define SIGQUIT 3 #define SIGILL 4 ...
SIGHUP (kill -1)
Action: disconnect process from its parent, usually restarting the process.
Example: kill -SIGHUP <PID> or kill -1 <PID>
SIGINT (kill -2)
Action: stop the process as if you pressed Ctrl+C. Many processes will respect this signal and stop, but they can also be programmed to ignore this basic signal.
Example: kill -SIGINT <PID>
SIGQUIT (kill -3)
Action: the same as SIGINT (so can be easily ignored) but also forcing the process to produce core dump (snapshot of its memory) before terminating.
Example: kill -SIGQUIT <PID> or kill -3 <PID>
SIGTRAP (kill -5)
Action: used for debugging. As a debugger goes through process execution step by step, it's possible to configure it to stop on given conditions and to activate the process trap – meaning process is stopped, no further instructions are executed.
Example: kill -SIGTRAP <PID> or kill -5 <PID>
SIGKILL (kill -9)
Action: immediately stop the process. By design, processes cannot be programmed to ignore this signal. No cleanup (chance for a process to stop gracefully, release memory or I/O resources) is requested or allowed – so it's an abrupt termination of a process.
Example: kill -SIGKILL <PID> or kill -9 <PID>
SIGSTOP (kill -19) and SIGCONT (kill -18)
Action: pause and continue execution of a process. If some process is taking up too much of CPU resource, you can temporarily stop it with SIGSTOP – process will still exist but won't be getting any CPU time to execute. You can later continue execution by sending the process SIGCONT signal.
Example: kill -SIGSTOP <PID> and kill -SIGCONT <PID>
SIGTERM (kill -15)
Action: graceful shutdown. The Unix process is given time to shutdown and to release its resources. Process is allowed to terminate properly rather than forced abruptly to stop.
Example: kill -SIGTERM <PID> or kill -15 <PID>
See Also
Leave a Reply