mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
180f86507d
PR-URL: https://github.com/nodejs/node/pull/14845 Fixes: https://github.com/nodejs/node/issues/14823 Refs: https://github.com/nodejs/node/pull/14822 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
34 lines
811 B
JavaScript
34 lines
811 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { spawn } = require('child_process');
|
|
for (const args of [[], ['-']]) {
|
|
const child = spawn(process.execPath, args, {
|
|
env: Object.assign({}, process.env, {
|
|
NODE_DEBUG: process.argv[2]
|
|
})
|
|
});
|
|
const wanted = `${child.pid}\n`;
|
|
let found = '';
|
|
|
|
child.stdout.setEncoding('utf8');
|
|
child.stdout.on('data', function(c) {
|
|
found += c;
|
|
});
|
|
|
|
child.stderr.setEncoding('utf8');
|
|
child.stderr.on('data', function(c) {
|
|
console.error(`> ${c.trim().split('\n').join('\n> ')}`);
|
|
});
|
|
|
|
child.on('close', common.mustCall(function(c) {
|
|
assert.strictEqual(c, 0);
|
|
assert.strictEqual(found, wanted);
|
|
}));
|
|
|
|
setTimeout(function() {
|
|
child.stdin.end('console.log(process.pid)');
|
|
}, 1);
|
|
}
|