Linux SIGKILL 信号处理程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3908694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SIGKILL signal Handler
提问by Poorna
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?
我可以注册 SIGTERM 但如何处理 SIGKILL 信号?
采纳答案by Chris Jester-Young
You cannot, at least not for the process being killed.
你不能,至少不能因为进程被杀死。
What you cando 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.
您可以做的是安排父进程监视子进程的死亡,并采取相应的行动。任何像样的过程监督系统,例如daemontools,都内置了这样的工具。