forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: make stdout & stderr block on all platforms
Fixes: nodejs#784
- Loading branch information
1 parent
2bb2f06
commit 6e7d435
Showing
3 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const add = 'test\n'; | ||
|
||
var str = ''; | ||
for (var i = 0; i < 1e5; i++) { | ||
str += add; | ||
} | ||
|
||
str += 'hey\n'; | ||
|
||
process.stdout.write(str); | ||
|
||
// Terminating the process appears to be required to achieve the regression | ||
// described in https://github.com/nodejs/io.js/issues/784. | ||
process.exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |