SIGCHLD not received

Marc Lehmann schmorp at
Tue May 29 20:08:16 CEST 2012

On Tue, May 29, 2012 at 09:57:30PM +0400, Denis Bilenko <denis.bilenko at> wrote:
> On Tue, May 29, 2012 at 7:12 PM, Marc Lehmann <schmorp at> wrote:
> > This one - your test program forks after initialising the default loop,
> > without calling ev_default_fork.
> OK, I've fixed the test program to do that and also fixed a fd leak.
> It takes a bit longer to fail now, but it still fails.

You also don't call waitpid on your children - can you add error checking
to all functions you call, to make sure you really do wait for your
children (especially check fork returns)? Most likely you run out of
process slots and fork fails, which your code "misinterprets" as a hang.

> > Note that this only works because the fork isn't done while the default
> > loop exists at the time - if you would fork while the dfeault loop
> > existed, you'd have to work with ev_default_fork and probably stop all
> > watchers you inherited form the parent.
> At the time of fork there no active watchers in the test program.

Well, there are, inside libev. But that's pretty irrelevant, the
documentation doesn't say you can ignore the fork if you don't have any
active watchers.

> To rule out epoll issues, I'm now using EVBACKEND_SELECT explicitly -
> still fails. There no pthreads either, so it has to be something else.

You still have to call ev_default_fork before you can reuse a loop in the
child, there are no exceptions.

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

More information about the libev mailing list