-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream: complete pipeline with stdio
stdio (stderr & stdout) should for compatibility reasons not be closed/end():ed. However, this causes pipeline with a stdio destination to never finish. This commit fixes this issue at a performance cost. Refs: #7606 Fixes: #32363 PR-URL: #32373 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 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,29 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const os = require('os'); | ||
|
||
if (process.argv[2] === 'child') { | ||
const { pipeline } = require('stream'); | ||
pipeline( | ||
process.stdin, | ||
process.stdout, | ||
common.mustCall((err) => { | ||
assert.ifError(err); | ||
}) | ||
); | ||
} else { | ||
const cp = require('child_process'); | ||
cp.exec([ | ||
'echo', | ||
'hello', | ||
'|', | ||
`"${process.execPath}"`, | ||
`"${__filename}"`, | ||
'child' | ||
].join(' '), common.mustCall((err, stdout) => { | ||
assert.ifError(err); | ||
assert.strictEqual(stdout.split(os.EOL).shift().trim(), 'hello'); | ||
})); | ||
} |