Reputation: 39
I am just wondering if there is a way to kill a userspace program from a kernel module.I know that kill command won't work as it is a system call from userspace to kernel space.
Upvotes: 1
Views: 2470
Reputation:
If you know what syscall can be used by userspace to deliver signals, why can't you check how it is implemented? More importantly though, why do you think you need to send a signal in the first place? How do you determine what to signal in the first place?
Is this another beyond terrible college assignment?
Upvotes: 0
Reputation: 11638
This code will kill the calling process...
int signum = SIGKILL;
task = current;
struct siginfo info;
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = signum;
int ret = send_sig_info(signum, &info, task);
if (ret < 0) {
printk(KERN_INFO "error sending signal\n");
}
You can see how the OOM killer does it here...
http://lxr.free-electrons.com/source/mm/oom_kill.c?v=3.16#L516
Upvotes: 5