Question

  1. Process B epolls on the pipe (EPOLLIN|EPOLLET).
  2. Process A writes 1KiB in pipe.
  3. Process B wakes up.
  4. Process B reads 1KiB from the pipe.
  5. Process A writes 1KiB in pipe.
  6. Process B epolls on the pipe.

The state of the pipe does not change during epoll, but has changed since the last read. Will process B wake up again?

Was it helpful?

Solution

My understanding from the FAQ (Q9) in http://linux.die.net/man/4/epoll is that you will get another event in step 6 (assuming that you can guarantee that step 5 really happens after step 4 and the pipe is empty after step 4).

Having said that, you might get more events than guaranteed (but you have to be careful only to rely on documented behavior) - see http://cmeerw.org/blog/753.html#753 and http://cmeerw.org/blog/750.html#750

OTHER TIPS

While it's true that the kernel wakes up on step 6, that is not what's documented by the manual page. The use case you provide does not conform to how EPOLLET is supposed to be used.

According to the documentation, step 6 should be "read from the FD". The only time you are supposed to poll from the FD is after you tried to read and got EAGAIN.

See also: What is the use case for EPOLLET?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top