From a09b747f30284b058b78ae71cf04380abc8d2a93 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 Fixes #1888. --- 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 8f26318939..fd23b5b571 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 1079d953d4..aebabc6c9d 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;