On Wed, Nov 28, 2012 at 8:57 PM, Richard Crowley <r...@rcrowley.org> wrote:
> How does the standard library cluster module pass a newly-opened file
> descriptor from a parent process to a child process in a way that
> allows the child process to accept(2) and not get EBADF?
>
> I made it to src/tcp_wrap.cc and from there into libuv and then got lost.
>
> I only care about Linux.  Does it use the CLONE_FILES flag to
> clone(2)? (I don't think it does because I can't find it in the source
> code but this seems to me like the only sane way to accomplish this.)

The child process inherits one end of an socketpair(AF_UNIX) tuple and
sendmsg() with CMSG_DATA() is used to send over file descriptors.  The
meat of the code is in uv__write() in src/unix/stream.c.

By the way, if you have more libuv specific questions, there's a libuv
mailing list: http://groups.google.com/group/libuv

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to