0

I am looking through code for FreeBSD. The code uses kevent programming interface. Now, I find the lines like below:

status = kevent(...)
if(status < 0){
 if(EINTR == errno){
  goto l_kevent;
 }
 /* ... */
}

I need to port the code for Linux, and I wonder... Should I check for EINTR with Linux epoll calls. I know that epoll has epoll_pwait, and it is still should be checked for EINTR. But the documentation I have on hand tells me nothing about the epoll_ctl calls being interruptible.

I can look into source code for epoll. But, as humble, as I am, I do not know how signals are handled in kernel. So, if the code itself relies on some interrupt mechanics, I do not know where to look for return codes of interest.

Hope I explained problem. The question, once again: my documentation tell me nothing on epoll_ctl being interruptible, what should I do? Should I check for EINTR?

P.S If someone will point me out for the source code for the epoll, that I can comprehend, I will gladly try to do my own research.

user14063792468
  • 839
  • 12
  • 28
  • 1
    `epoll_ctl()` doesn't potentially block waiting for something, so afaik it can't be interrupted by a signal. The man page doesn't list `EINTR` as a possible error code for it... – Shawn Dec 25 '22 at 18:27
  • @Shawn Your logic makes sense. I was confused by FreeBSD code. Maybe I should close the question. Now I see that it is really as you suggested. – user14063792468 Dec 25 '22 at 18:47
  • 1
    @user14063792468, `kevent()` is a dual-use interface: it serves both to register interest in one or more events *and* to return events to the caller. It potentially blocks when retrieving events, which is the analogue of `epoll_wait()`, but the documentation specifies that it *does not* block otherwise, which would include when operating strictly analogously to `epoll_ctl()`. The docs are also fairly clear with respect to `EINTR` specifically, that it indicates termination due to a signal prior to timeout or queueing any events *to return*. – John Bollinger Dec 25 '22 at 19:02

0 Answers0