mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
98b6b2d840
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: https://github.com/nodejs/node/issues/7606 Fixes: https://github.com/nodejs/node/issues/32363 PR-URL: https://github.com/nodejs/node/pull/32373 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
30 lines
623 B
JavaScript
30 lines
623 B
JavaScript
'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');
|
|
}));
|
|
}
|