Hi,

I've read up on the PR <https://github.com/libuv/libuv/pull/846> and others 
related  to fork(). I've seen 

int uv_loop_fork <http://docs.libuv.org/en/latest/loop.html#c.uv_loop_fork>(
uv_loop_t <http://docs.libuv.org/en/latest/loop.html#c.uv_loop_t> *loop)

is marked experimental. Furthermore, if I understand fork(2) 
<https://www.man7.org/linux/man-pages/man2/fork.2.html> correctly, then a 
multi-threaded program is *never* save to fork() without exec.

*> After a fork() in a multithreaded program, the child can safely call 
only async-signal-safe functions (see signal-safety(7) 
<https://www.man7.org/linux/man-pages/man7/signal-safety.7.html>) until 
such time as it calls execve(2) 
<https://www.man7.org/linux/man-pages/man2/execve.2.html>. *

Is there some guidance as to what functionality is save to use prior to 
fork with libuv? 

Which parts of libuv use threads and which parts are guaranteed not to?

*Use case:*

Prior to fork() I need socket/accept and/or pipe operations, and then want 
to setup SIGCHLD handlers, i.e. the parent  will fork() many times and keep 
tabs on children, and re-fork() them when they die. In the child I need to 
get rid of the parent's listener socket and signal handlers, and only keep 
the socket and/or the right ends of pipes.

_Mark

On Monday, May 23, 2016 at 9:44:24 PM UTC+2 [email protected] wrote:

> Hi all,
>
> As per this discussion, I've been working on 
> https://github.com/libuv/libuv/pull/846. I'm happy to report that I 
> haven't run into any insurmountable issues. I pushed some more commits 
> today, bringing the tested set of working platforms up to:
>
> - Mac OS X 10.11
> - Linux x86
> - Linux arm
> - FreeBSD 10
> - Solaris 11
>
> (I don't have access to AIX so I haven't been able to test there and I 
> didn't want to code blindly, so building on AIX will fail with a linker 
> error. I'll need some help for that platform.)
>
> No doubt the PR needs some fine tuning, but I hope it's in a state that 
> can be usefully discussed. I've left more detailed comments on the PR 
> itself.
>
> Thanks for all the pointers in this thread!
>
> Jason
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/libuv/2424671e-3478-4040-9b93-7f566cbf31a0n%40googlegroups.com.

Reply via email to