Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

child_process.fork: don't modify args #1888

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function nop() { }
exports.fork = function(modulePath, args, options) {
if (!options) options = {};

if (!args) args = [];
args = args ? args.slice(0) : [];
args.unshift(modulePath);

if (options.stdinStream) {
Expand Down
4 changes: 3 additions & 1 deletion test/simple/test-child-process-fork.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
var assert = require('assert');
var common = require('../common');
var fork = require('child_process').fork;
var args = ['foo', 'bar'];

var n = fork(common.fixturesDir + '/child-process-spawn-node.js');
var n = fork(common.fixturesDir + '/child-process-spawn-node.js', args);
assert.deepEqual(args, ['foo', 'bar']);

var messageCount = 0;

Expand Down