a flag of libev about ev_default_fork

simon zhang hapopen at gmail.com
Wed Aug 1 15:46:52 CEST 2012


Hi,guys
I'm learning libev. But i don't understand about the ev_default_fork flag
of ev_loop. Is this a question of close-on-exec?Like the FD_CLOEXEC fcntl()
flag do? when i need to set the flag?which case this flag is necessary?
This a description of doc:

> This function sets a flag that causes subsequent ev_loop iterationsto
> reinitialise the kernel state for backends that have one. Despite thename,
> you can call it anytime, but it makes most sense after forking, inthe child
> process (or both child and parent, but that again makes littlesense). You
> must call it in the child before using any of the libevfunctions, and it
> will only take effect at the next ev_loop iteration.
> On the other hand, you only need to call this function in the childprocess
> if and only if you want to use the event library in the child. Ifyou just
> fork+exec, you don't have to call it at all.
> The function itself is quite fast and it's usually not a problem to callit
> just in case after a fork. To make this easy, the function will fit inquite
> nicely into a call to pthread_atfork: pthread_atfork (0, 0,
> ev_default_fork);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20120801/7ab65d75/attachment.html>


More information about the libev mailing list