Sending signals from the kernel to user space

I am working on a Linux embedded project at the moment with one simple small requirement : when a certain event occurs within a kernel driver, I need to locate a listening user-space process and signal it somehow.

(1) How can I locate the PID of the specific process I want to handle this ? Can I query for the PID by name ?

(2) Once I have the PID, is it simply a matter of using sys_signal() to send the signal to the process ?

Thanks in advance for any help possible.

--

"Jokes mentioning ducks were considered particularly funny." - cnn.com
Reply to
Chesney Christ
Loading thread data ...

I assume you are writing or at least customising the driver? If so, you could add an IOCTL call to the driver, which the user program makes to register its PID with the driver.

send_signal() looks better for this purpose. Get the driver to create and populate a siginfo and sigpending structures, and pass pointers to send_signal.

Regards,

John

Reply to
John Williams

This sounds like it's exactly the ticket. I'll check it out.

Wonderful - exactly the kind of thing I had in mind. Thanks.

--

"Jokes mentioning ducks were considered particularly funny." - cnn.com
Reply to
Chesney Christ

Do you _really_ need to send a signal to the processor ?

The standard way to do a ready message to a user process is using normal I/O. E.g. a blocking read to the device file done by the user process could be freed on ready (see e.g. "rtc.c" in the standard distribution as an example). Moreover (e.g. with a "select" statement and IOCTL) the user program can inform itself about the state of the device without being blocked simply using the device file interface.

-Michael

Reply to
Michael Schnell

The reason why this is a little inappropriate is because I'm supporting a proprietary network stack, on an embedded Linux setup, which must run in user space for a number of reasons. So I'm going to have a network driver in the kernel which will handle and clear the actual interrupts from the network hardware, and then signal the user space task to come and collect the data.

--

"Jokes mentioning ducks were considered particularly funny." - cnn.com
Reply to
Chesney Christ

Look again! The normal I/O you do could just be a dummy byte saying "I/O ready, go do your thing!".

By the way, netlink sockets are very, very easy to use, and pretty fast. You might try 'em out.

- Dan

Reply to
Dan Kegel

Thanks for that tip - I just googled for that, and the technique seems to provide a standard way of implementing this kind of communication - sounds ideal.

--

"Jokes mentioning ducks were considered particularly funny." - cnn.com
Reply to
Chesney Christ

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.