查看系统所有信号:
kill -l
man 7 signal
SIGINT: 2号。相当于ctrl-c。程序捕获该“信号”,执行诸如释放资源的操作,退出。
SIGTERM: 15号。通过另一个程序发出。效果与SIGINT类似。
这两个信号的效果都取决于“被杀死”进程的程序是如何处理这两个信号的。因为他们是可以被捕获的。
SIGKILL: 9号。粗暴的强制杀死进程,进程没有机会做释放资源的操作。
kill -s 15 10956
请看GNU C Library对三个信号的解释:
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 SIGINT (“program interrupt”) signal is sent when the user types the INTR character (normally Ctrl-c).
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.
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 Ctrl-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.
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 possibly continue to run (even to run a signal handler).