2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-03-26 15:26:15 -07:00
|
|
|
const common = require('../common');
|
|
|
|
const spawn = require('child_process').spawn;
|
2014-06-10 19:36:04 -04:00
|
|
|
|
2016-03-26 15:26:15 -07:00
|
|
|
if (process.argv[2] === 'child') {
|
|
|
|
process.stdin.resume();
|
|
|
|
process.stdin._handle.close();
|
|
|
|
process.stdin._handle.unref(); // Should not segfault.
|
2016-07-15 15:43:24 -04:00
|
|
|
process.stdin.on('error', common.mustCall(function(err) {}));
|
2016-03-26 15:26:15 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use spawn so that we can be sure that stdin has a _handle property.
|
|
|
|
// Refs: https://github.com/nodejs/node/pull/5916
|
|
|
|
const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'pipe' });
|
|
|
|
|
|
|
|
proc.stderr.pipe(process.stderr);
|
|
|
|
proc.on('exit', common.mustCall(function(exitCode) {
|
|
|
|
if (exitCode !== 0)
|
|
|
|
process.exitCode = exitCode;
|
|
|
|
}));
|