Mixing async and sync after a fork

Brandon Black blblack at gmail.com
Thu Jan 10 17:18:04 CET 2013

On Thu, Jan 10, 2013 at 10:05 AM, Bo Lorentsen <bl at lue.dk> wrote:

> The thing is ... this works amazingly, until I try to startup this app as
> a daemon (fork). And yes, when i start it as i daemon i make sure to call
> ev::post_fork(), and my default loop starts up as it is supposed to (but
> later or lazy really), without any problems (in its own libev thread), but
> it seems like any socket connections made after the fork between
> ev::post_fork() and ev::default_loop().run() are invalid after calling run.

You shouldn't even need post_fork() just to do daemonization.  Just
daemonize first and then initialize libev stuff afterwards.  My first
random guess at your problem would be that you're using some daemonization
library/code written by someone else, and that it closes all open file
descriptors during the process (a common programming error in daemonization
code).  I've use libev in a ton of daemonized C code without issue, as I'm
sure many others have, so it's unlikely to be a bug in libev.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20130110/01aeb693/attachment.html>

More information about the libev mailing list