Reputation: 558
I have a kernel module that has a while(1) loop in the init routine that is supposed to run infinitely.
If I have an equivalent code in a user space program, when I press Control+C the user space program is terminated, however this is not the case for a kernel module.
Is there a way to send a kill signal to the kernel module (when it is still running its init routine) so it can terminate / exit ?
Thanks in advance
Upvotes: 3
Views: 1645
Reputation: 66153
In kernel you may use signal_pending()
or fatal_signal_pending()
for check whether signal/fatal signal is arrived:
while(!fatal_signal_pending(current) {
// infinite loop
}
So, you may press Control+C for insmod <your-module.ko>
, and module's init function will terminate the loop.
Kernel thread (created with kthread_create()
or similar) may catch signals only if it allows them with allow_signal()
Upvotes: 5