LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-10-2017, 11:17 AM   #1
yaronshr
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Rep: Reputation: Disabled
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).

Thanks!
 
Old 04-11-2017, 06:45 PM   #2
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
I think maybe you need to install an Interrupt Handler? <guessing>
http://www.makelinux.net/ldd3/chp-10-sect-2

http://www.tldp.org/LDP/lkmpg/2.4/html/x1210.html

https://www.google.com/search?q=webc...kernel+module+

HTH

Good Luck-
 
Old 04-12-2017, 10:28 AM   #3
yaronshr
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
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.
 
Old 04-12-2017, 02:30 PM   #4
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by yaronshr View Post
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.-
 
Old 04-12-2017, 07:54 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
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.
 
  


Reply

Tags
crash, interrupt, kernel module, signal



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send signal from user space to kernel module zerop Programming 2 08-02-2014 08:38 AM
“Attach” a user space process from Linux kernel/kernel module WoodBunny Linux - Kernel 2 05-23-2014 06:14 PM
how to send events from kernel module to user space process yugandhar Linux - Kernel 2 02-21-2011 10:39 AM
How to send a signal from a module to a process haha Linux - Kernel 10 04-28-2010 02:48 AM
Fetchmail terminates with signal 15 teeka Linux - Networking 0 05-19-2004 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration