Interrupt a kernel module when a user process terminates/receives a signal?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Interrupt a kernel module when a user process terminates/receives a signal?
I am working on a kernel module where I need to be "aware" that a given process has crashed.
Right now my approach is to set up a periodic timer interrupt in the kernel module; on every timer interrupt, I check the task_struct.state and task_struct.exitstate values for that process.
I am wondering if there's a way to set up an interrupt in the kernel module that would go off when the process terminates, or, when the process receives a given signal (e.g., SIGINT or SIGHUP).
Thank you Ztcorcat; I think the crux would be, what kind of interrupt is available to set up to trigger the interrupt handler - i.e., whether it is possible to set up an interrupt that would fire when a user process receives a signal or terminates.
I has been suggested to me elsewhere to set up a character device and put a signal handler into the process that sends a message to the character device. It has also been suggested to me to use a watchdog timer. But here's another kink: I really don't want to modify the user process code - I don't think my customer would go for that type of solution.
Thank you Ztcorcat; I think the crux would be, what kind of interrupt is available to set up to trigger the interrupt handler - i.e., whether it is possible to set up an interrupt that would fire when a user process receives a signal or terminates.
I has been suggested to me elsewhere to set up a character device and put a signal handler into the process that sends a message to the character device. It has also been suggested to me to use a watchdog timer. But here's another kink: I really don't want to modify the user process code - I don't think my customer would go for that type of solution.
You're Welcome.
Sorry I've never used Watchdog timer.
If your customer doesn't want the process code modified I can see where that could make it difficult for you.
Maybe other members will chime in and know what you could try.
If you don't know what to do than do what you know.-
Another idea that comes to mind is that you could implement the thing as a virtual filesystem. In other words, the client process opens the "file," then uses read/write/ioctl semantics to manipulate it. If the process terminates, all of its file-handles will be closed, thus giving you automatic notification of the event.
Perhaps you could put the monkey on the user-process's back, requiring it to set its own signal-handler and to, say, issue some ioctl() call against the file-handler if the handler goes off.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.