[PATCH] ev: fix epoll_init fd leak

Marc Lehmann schmorp at schmorp.de
Tue Nov 1 01:16:46 CET 2011

On Mon, Oct 31, 2011 at 09:07:39PM +0100, Jonathan Neuschäfer <j.neuschaefer at gmx.net> wrote:
> > 0 is, in fact, not a valid file descriptor in this case, as it is stdin,
> > and an epoll fd is not having the properties stdin has - althoguh it'S
> > much betterto have an epoll fd there than, say, your shadow file :)
> As this is not exactly the same as checking for a simple error, I think
> this line needs a comment why it checks for <= 0 and not < 0.

The check for <= 0 is inconsistent and incomplete - libev should either
check for <= 2 in all such tests, which gives best coverage of system-fds,
or always < 0. Alternatively, it could do what urxvt does and fix up fds
0..2 on init, with warning, as it seems to be a common bug.

But this is a quality issue - libev doesn't really give a useful
diagnostic in this case, although no harm will be done as it is (libev
does not and cannot guarantee atomicity w.r.t. concurrent exec, and libev
will work under these conditions).

The real issue was and is the broken app that messes with system fds. It
needs fixing in any case.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list