mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 20:29:23 +01:00
cbc3ef64ce
Allow reading from stdio streams that are conventionally associated with process output, since this is only convention. This involves disabling the oddness around closing stdio streams. Its purpose is to prevent the file descriptors 0 through 2 from being closed, since doing so can lead to information leaks when new file descriptors are being opened; instead, not doing anything seems like a more reasonable choice. Fixes: https://github.com/nodejs/node/issues/21203 PR-URL: https://github.com/nodejs/node/pull/23053 Reviewed-By: James M Snell <jasnell@gmail.com>
33 lines
688 B
JavaScript
33 lines
688 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
if (process.argv[2] === 'child')
|
|
process.stdout.end('foo');
|
|
else
|
|
parent();
|
|
|
|
function parent() {
|
|
const spawn = require('child_process').spawn;
|
|
const child = spawn(process.execPath, [__filename, 'child']);
|
|
let out = '';
|
|
let err = '';
|
|
|
|
child.stdout.setEncoding('utf8');
|
|
child.stderr.setEncoding('utf8');
|
|
|
|
child.stdout.on('data', function(c) {
|
|
out += c;
|
|
});
|
|
child.stderr.on('data', function(c) {
|
|
err += c;
|
|
});
|
|
|
|
child.on('close', function(code, signal) {
|
|
assert.strictEqual(code, 0);
|
|
assert.strictEqual(err, '');
|
|
assert.strictEqual(out, 'foo');
|
|
console.log('ok');
|
|
});
|
|
}
|