Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 我可以修改SIGKILL的信号处理程序的代码吗_Linux_Linux Kernel_Signals_Sigkill - Fatal编程技术网

Linux 我可以修改SIGKILL的信号处理程序的代码吗

Linux 我可以修改SIGKILL的信号处理程序的代码吗,linux,linux-kernel,signals,sigkill,Linux,Linux Kernel,Signals,Sigkill,如何修改SIGKILL的信号处理程序的代码,以便重新定义SIGKILL的acitin?您需要定义一个函数来处理异常情况: #include <stdio.h> #include <execinfo.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> void ExceptionHandler(int sig) { #define MAXSTACKSIZE

如何修改SIGKILL的信号处理程序的代码,以便重新定义SIGKILL的acitin?

您需要定义一个函数来处理异常情况:

#include <stdio.h>
#include <execinfo.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

void ExceptionHandler(int sig)
{
    #define MAXSTACKSIZE (16)
    void *stackTraces[MAXSTACKSIZE];
    size_t size;

    // get void*'s for all entries on the stack
    size = backtrace(stackTraces, MAXSTACKSIZE);

    // do other stuffs of your own

    exit(1);
}
希望这对你有帮助。你不能。
无法捕获、阻止或忽略信号SIGKILL和SIGSTOP。
阅读更多内容

我可以修改与SIGKILL处理程序相关的内核代码并重新编译内核以重新定义我自己的操作吗?当然可以,但为什么需要这样做?让进程始终运行?好吧,现在我正在学习内核,我收到了一个任务:为特定进程重新定义SIGKILL的操作。例如,当我使用kill-9PID命令时,PID的进程不会被终止。那我该怎么办?你需要编辑你的问题并添加标签[家庭作业]。我不是一个内核编码器,但我想你需要修改信号传递代码,而不仅仅是信号处理代码。我知道了!非常感谢。刚开始!我不知道如何处理它。首先,在内核源代码中搜索与信号处理和传递相关的函数。然后,阅读源代码,直到您理解它是如何工作的。然后,进行修改。在内核中,如何实现它?
signal(SIGSEGV, ExceptionHandler);
signal(SIGTERM, ExceptionHandler);
signal(SIGINT, ExceptionHandler);
signal(SIGILL, ExceptionHandler);
signal(SIGABRT, ExceptionHandler);
signal(SIGFPE, ExceptionHandler);