diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 6f396fac6c..cd5313d65c 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -217,7 +217,7 @@ util.inherits(ChildProcess, EventEmitter); function flushStdio(subprocess) { if (subprocess.stdio == null) return; subprocess.stdio.forEach(function(stream, fd, stdio) { - if (!stream || !stream.readable || stream._consuming) + if (!stream || !stream.readable) return; stream.resume(); }); diff --git a/test/parallel/test-child-process-flush-stdio.js b/test/parallel/test-child-process-flush-stdio.js new file mode 100644 index 0000000000..5fd7eb3bc9 --- /dev/null +++ b/test/parallel/test-child-process-flush-stdio.js @@ -0,0 +1,17 @@ +'use strict'; +const cp = require('child_process'); +const common = require('../common'); +const assert = require('assert'); + +const p = cp.spawn('echo'); + +p.on('close', common.mustCall(function(code, signal) { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); +})); + +p.stdout.read(); + +setTimeout(function() { + p.kill(); +}, 100);