libev epoll and EPOLLRDHUP

Chaliha, Sayan sayan.chaliha at
Thu Jun 13 08:30:38 CEST 2013

Hey Marc,

I also have another question, something I've been trying to figure out without any luck: Is there any possibility that libev's backend_fd gets corrupted and epoll_wait returns either EINVAL or EBADF? I just upgraded to 4.15 from 4.10. I was seeing the problem in 4.10. Obviously my application code doesn't access backend_fd directly...

Warm regards,

-----Original Message-----
From: Marc Lehmann [mailto:schmorp at] 
Sent: Thursday, June 13, 2013 5:01 AM
To: Chaliha, Sayan
Cc: libev at
Subject: Re: libev epoll and EPOLLRDHUP

On Wed, Jun 12, 2013 at 05:19:31PM +0530, "Chaliha, Sayan" <sayan.chaliha at> wrote:
> I'd like a notification from libev when a TCP connection goes down. 
> This works fine with poll backend, but with epoll backend it doesn't. 
> My guess is because EPOLLRDHUP is not being handled. Could I have a 
> patch for this please?

Hi - this doesn't make much sense: libev already notifies you when a tcp connection goes down (for both read and write watcher depending on which half is closed). It makes no obvious sense for libev to handle EPOLLRDHUP in any way.

Could you describe:

- what behaviour you are seeing.
- what behaviour do you expect instead.
- what exactly you think should be changed.
- how poll differs from epoll in generated signals.

Also, since epoll is extremely badly designed and implemented, maybe you are hitting a bug in your kernel - which kernel version do you see the beahviour with?

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list