Linux kernel module signal on userspace process killed

假装没事ソ 提交于 2019-12-12 08:55:00

问题


I'm wondering if there is a hook that could be used in a Linux Kernel Module that is fired when a user space application/process is killed ?


回答1:


You could first register for a notifier chain within your kernel module.

Inside get_signal_to_deliver(kernel/signal.c), any process which has just (this being a relative term IMHO) been killed has its PF_SIGNALED flag being set. Here you could check for the name of the current process using its tcomm field like so:

char tcomm[sizeof(current->comm)];
get_task_comm(tcomm, current);

If it is indeed the process under question, you could just fire the notification chain which will awaken your module which has been waiting on that chain.



来源:https://stackoverflow.com/questions/15178257/linux-kernel-module-signal-on-userspace-process-killed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!