2

I have been learning about different IPC mechanisms present in Linux, for communication between user space processes.

I want to ask what are various ways in Linux for the kernel to communicate with the user space process (kind of opposite to system call, where user space initiates request) ? Can signal be one of them ? What are the others ?

closed as too broad by Celada, Stephen Kitt, Anthon, Michael Homer, taliezin Jun 22 '15 at 7:15

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

A signal is a classic kernel-to-process communication in some cases. Sure, any process with appropriate UID can use kill() to send a signal, but signals like SIGCHLD or SIGWINCH almost always come from the kernel.

Specific to Linux, you can look at the signalfd() system call. The usual signal handling is via an "upcall", but signalfd() gives a process a different way of receiving signals.

The return value of system calls could be considered a kernel-to-user process communication. This varies a lot, but fork() is an example. The parent process gets back a non-zero process ID (or -1 on error) and the child process gets back zero.

The poll() and select() system calls have arguments where the kernel sets values in the arguments to indicate which file descriptors have which events/state changes available to them. That's more like an "inout" formal argument, but the kernel does set values.

The inotify API allows kernel-to-process communication via a read() on a special file descriptor.

The POSIX asynchronous I/O system seems to have multiple ways to communicate with a user process, including starting a thread when an I/O occurs, if I read the man page correctly. I've never done POSIX async I/O, and it looks tricky.

Not the answer you're looking for? Browse other questions tagged or ask your own question.