// Prepare arguments for fork:
execArgv = options.execArgv || process.execArgv;
+
+ if (execArgv === process.execArgv && process._eval != null) {
+ const index = execArgv.lastIndexOf(process._eval);
+ if (index > 0) {
+ // Remove the -e switch to avoid fork bombing ourselves.
+ execArgv = execArgv.slice();
+ execArgv.splice(index - 1, 2);
+ }
+ }
+
args = execArgv.concat([modulePath], args);
// Leave stdin open for the IPC channel. stdout and stderr should be the
var common = require('../common'),
assert = require('assert'),
child = require('child_process'),
+ path = require('path'),
nodejs = '"' + process.execPath + '"';
function(status, stdout, stderr) {
assert.equal(stdout, "[ '--use-strict', '-p', 'process.execArgv' ]\n");
});
+
+// Regression test for https://github.com/nodejs/node/issues/3574
+const emptyFile = path.join(common.fixturesDir, 'empty.js');
+child.exec(nodejs + ` -e 'require("child_process").fork("${emptyFile}")'`,
+ function(status, stdout, stderr) {
+ assert.equal(stdout, '');
+ assert.equal(stderr, '');
+ });