mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
8b76c3e60c
PR-URL: https://github.com/nodejs/node/pull/12735 Refs: https://github.com/nodejs/node/pull/12455 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
33 lines
748 B
JavaScript
33 lines
748 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
|
const child = spawn(process.execPath, [], {
|
|
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);
|
|
console.log('ok');
|
|
}));
|
|
|
|
setTimeout(function() {
|
|
child.stdin.end('console.log(process.pid)');
|
|
}, 1);
|