child_process: flush consuming streams
authorDave <dave@jut.io>
Mon, 30 Nov 2015 10:41:51 +0000 (02:41 -0800)
committerMyles Borins <mborins@us.ibm.com>
Tue, 19 Jan 2016 19:52:31 +0000 (11:52 -0800)
commit48564204f01fc39b08a9ba2f4631e32c0d800ead
tree1e117ad8a400854d7e09f212a58349a32c5c0679
parentf4414102edac3bd352fbc653dfe6220d617e4c35
child_process: flush consuming streams

When a client calls read() with a nonzero argument
on a Socket, that Socket sets this._consuming to true.
It never sets this._consuming back to false.
ChildProcess.flushStdio() currently doesn't flush
any streams where _consuming is truthy. But, that means
that it never flushes any stream that has ever been read from.
This prevents a child process from ever closing if one of
its streams has been read from, causing issue #4049. This
commit allows consuming streams to be flushed, and the
child process to emit a close event.

Fixes: https://github.com/nodejs/node/issues/4049
PR-URL: https://github.com/nodejs/node/pull/4071
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
lib/internal/child_process.js
test/parallel/test-child-process-flush-stdio.js [new file with mode: 0644]