From 175a2865198a55cbe1c32d8db756411b1af600ab Mon Sep 17 00:00:00 2001 From: koichik Date: Fri, 14 Oct 2011 17:04:04 +0900 Subject: [PATCH] child_process.fork: don't modify args --- lib/child_process.js | 2 +- test/simple/test-child-process-fork.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/child_process.js b/lib/child_process.js index 8f263189395a..fd23b5b57164 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -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) { diff --git a/test/simple/test-child-process-fork.js b/test/simple/test-child-process-fork.js index 1079d953d449..aebabc6c9d14 100644 --- a/test/simple/test-child-process-fork.js +++ b/test/simple/test-child-process-fork.js @@ -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;