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

Child process options should not override env #1789

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/child_process.js
Expand Up @@ -219,7 +219,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {
options.uid === undefined) { options.uid === undefined) {
// Deprecated API: (path, args, options, env, customFds) // Deprecated API: (path, args, options, env, customFds)
cwd = ''; cwd = '';
env = options || process.env; env = process.env;
customFds = customFds || [-1, -1, -1]; customFds = customFds || [-1, -1, -1];
setsid = false; setsid = false;
uid = -1; uid = -1;
Expand Down
12 changes: 12 additions & 0 deletions test/simple/test-child-process-env.js
Expand Up @@ -42,7 +42,19 @@ child.stdout.addListener('data', function(chunk) {
response += chunk; response += chunk;
}); });


var child2 = spawn('/usr/bin/env', [], {});
var response2 = '';

child2.stdout.setEncoding('utf8');

child2.stdout.addListener('data', function(chunk) {
console.log('stdout2: ' + chunk);
response2 += chunk;
});

process.addListener('exit', function() { process.addListener('exit', function() {
assert.ok(response.indexOf('HELLO=WORLD') >= 0); assert.ok(response.indexOf('HELLO=WORLD') >= 0);
assert.ok(response.indexOf('FOO=BAR') >= 0); assert.ok(response.indexOf('FOO=BAR') >= 0);

assert.ok(response2.indexOf('PATH=') >= 0);
}); });