Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在收到任何终止命令(如 SIGTERM 和 SIGKILL)时写入日志文件。
我可以注册 SIGTERM 但如何处理 SIGKILL 信号?
你不能,至少不能因为进程被杀死。
您可以做的是安排父进程监视子进程的死亡,并采取相应的行动。任何像样的进程监控系统,例如daemontools,都内置了这样的工具。