在 Linux 下捕获 SIGKILL 的 C++ 程序

C++ program that catches SIGKILL under Linux

我想在我的进程在 linux 中收到 SIGKILL 时创建一个核心。 我尝试捕捉到这个信号,但似乎无法捕捉到SIGKILL。

正确,根据 man page for sigaction:

signum specifies the signal and can be any valid signal except SIGKILL and SIGSTOP.

这几乎一直都是这种情况,你真的不想给进程处理所有信号的能力因为这会让你到达只能被电源循环杀死的地步:-)