Fork watcher will not be called if fork() is invoked in prepare watcher callback.

Marc Lehmann schmorp at
Sun May 4 04:10:09 CEST 2014

On Sat, May 03, 2014 at 12:49:23PM +0200, Denis Bilenko <denis.bilenko at> wrote:
> It seemed to make sense to do it prepare watcher. Are you saying that
> doing this in idle watcher (with highest priority) would be more
> appropriate?

I don't know exactly what a greenlet is, but it really depends on what you
allow them to do - as long as they abide by the limitations that prepare
watchers put on them, it's fine to run them there. If they can't (because
they need to fork or enter the mainloop or do anything else not allowed in a
prepare watcher), then you can't run them in prepare watchers.

In the latter case, an idle watcher would be the second best thing - they
don't have special limitations. Which priority to use for them I can't say
- it depends on whether you want them to preempt other idle watchers or

Another alternative would be a check watcher, which also has no special
limitations (but you probably need an idle watcher to keep the mainloop
from blocking).

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

More information about the libev mailing list