joyent/node — pull request #5869 by mojodna (2013-07-19 05:27:25+00:00)
Title: child_process: Set additional fds as read/write

When a `ChildProcess`'s `stdio` configuration includes additional file descriptors, those fds should be set as read/write to prevent `uv_shutdown from setting `ENOTCONN` when calling end() on the `Socket` wrapper.

Pre-libuv handling: https://github.com/joyent/node/blob/8417870f513e6f1ab98e07fe95d3430dbec48b87/lib/net.js#L851-L853

Where `uv_shutdown` sets `ENOTCONN`: https://github.com/joyent/libuv/blob/3ee4d3f183331a123ce35edd0d32268a2bb22aa5/src/unix/stream.c#L1090-L1095

This still needs tests, but I'm curious what y'all think (and to put my thinking down).

I'm seeing it when I pipe multiple `Buffer`s to ImageMagick via additional fds using `Socket#end()`. (See "STDIN, STDOUT, and file descriptors" in http://www.imagemagick.org/script/command-line-processing.php)