diff --git a/lib/net.js b/lib/net.js index 76c6f1d8891a90..53c76af64afd17 100644 --- a/lib/net.js +++ b/lib/net.js @@ -125,9 +125,7 @@ function Socket(options) { this._handle = createHandle(options.fd); this._handle.open(options.fd); if ((options.fd == 1 || options.fd == 2) && - (this._handle instanceof Pipe) && - process.platform === 'win32') { - // Make stdout and stderr blocking on Windows + this._handle instanceof Pipe) { var err = this._handle.setBlocking(true); if (err) throw errnoException(err, 'setBlocking'); diff --git a/test/fixtures/stdout-producer.js b/test/fixtures/stdout-producer.js new file mode 100644 index 00000000000000..8aadbb51e03f27 --- /dev/null +++ b/test/fixtures/stdout-producer.js @@ -0,0 +1,13 @@ +'use strict'; + +const add = 'test\n'; + +var str = ''; +for (var i = 0; i < 100000; i++) { + str += add; +} + +str += 'hey\n'; + +process.stdout.write(str); +process.exit(); diff --git a/test/parallel/test-child-process-chunked-stdout.js b/test/parallel/test-child-process-chunked-stdout.js new file mode 100644 index 00000000000000..76a12884be875a --- /dev/null +++ b/test/parallel/test-child-process-chunked-stdout.js @@ -0,0 +1,27 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const fork = require('child_process').fork; +const stream = require('stream'); +const path = require('path'); + +const producer = fork(path.join(common.fixturesDir, 'stdout-producer.js'), + { silent: true }); + +var found = ''; +const writable = new stream.Writable({ + write (chunk, _, next) { + const lines = chunk.toString().split('\n'); + + found = lines[lines.length - 2]; + next(); + } +}) + +producer.stdout.pipe(writable); +producer.stdout.on('close', function() { + assert.strictEqual(found, 'hey'); +}) + +producer.stderr.pipe(process.stderr);