SIGKILL信号处理程序 [英] SIGKILL signal Handler

查看:135
本文介绍了SIGKILL信号处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在接收到任何终止命令(如SIGTERM和SIGKILL)时写入日志文件.

I have a requirement to write to a log file on reception of any terminate command like SIGTERM AND SIGKILL.

我可以注册SIGTERM,但是如何处理SIGKILL信号?

I can register for SIGTERM but how can handle the SIGKILL signal?

推荐答案

您不能,至少不是因为该进程被杀死.

You cannot, at least not for the process being killed.

您可以 做的是安排父进程监视子进程的死亡,并采取相应的措施.任何体面的过程监督系统(例如 daemontools )都内置有这样的工具.

What you can do is arrange for the parent process to watch for the child process's death, and act accordingly. Any decent process supervision system, such as daemontools, has such a facility built in.

这篇关于SIGKILL信号处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆