child_process: fix data loss with readable event
authorBrian White <mscdex@mscdex.net>
Tue, 2 Feb 2016 05:57:24 +0000 (00:57 -0500)
committerMyles Borins <mborins@us.ibm.com>
Wed, 2 Mar 2016 22:01:11 +0000 (14:01 -0800)
commitab787ad0ab1955bcde484507839e2159d44e6e25
tree4e8a5daf3b4a054570b6d9701506fdbc4b472b7a
parentc0facfbfe6927cda16e42ac16e3cb8e330f4c473
child_process: fix data loss with readable event

This commit prevents child process stdio streams from being
automatically flushed on child process exit/close if a 'readable'
event handler has been attached at the time of exit.

Without this, child process stdio data can be lost if the process
exits quickly and a `read()` (e.g. from a 'readable' handler)
hasn't had the chance to get called yet.

Fixes: https://github.com/nodejs/node/issues/5034
PR-URL: https://github.com/nodejs/node/pull/5036
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
lib/internal/child_process.js
test/parallel/test-child-process-flush-stdio.js