joyent/node — pull request #3031 by eladb (2012-03-29 08:31:11+00:00)
Title: Close child pipes when child exits (+ test)

This essentially fixes joyent/node#818: when a child process exits, `stdout` and `stderr` are now closed.

There seems to be a difference in behavior between Windows and Unix in this scenario. Even if a child process spawns a grandchild, on unix, when a child exits, the stdout/stderr pipes associated with it are broken so that parent process streams are closed automatically. On Windows, the pipes remain open until the grandchild exits.

The current implementation in node will wait for the streams to be closed before emitting the `exit` event (even though the child already exited).

See discussion in joyent/libuv#343. It seems that the preferred solution is to make this fix at the node level instead of libuv.

The associated test (`simple/test-child-process-tree`) fails without this patch only on Windows.

Contributed: @yosefd @saary