Linux signals

查看系统所有信号:

kill -l
man 7 signal


Kill相关

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).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值