Skip to content

Commit

Permalink
Drop undefined/null values from child process env
Browse files Browse the repository at this point in the history
Undefined LANG was causing an actual LANG="undefined" to be passed
to the child process.
  • Loading branch information
jcheng5 committed Jun 10, 2014
1 parent 39d7aff commit 0b5c72d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions lib/core/map.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var _ = require('underscore');

/*
* map.js
*
Expand All @@ -17,4 +19,15 @@ exports.create = create;
*/
function create() {
return Object.create(null);
}

exports.compact = compact;
/**
* Return a copy of object x with null or undefined "own" properties removed.
*/
function compact(x) {
function shouldDrop(key) {
return typeof(x[key]) === 'undefined' || x[key] === null;
}
return _.omit(x, _.filter(_.keys(x), shouldDrop))
}
5 changes: 3 additions & 2 deletions lib/worker/app-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var util = require('util');
var bash = require('bash');
var Q = require('q');
var _ = require('underscore');
var map = require('../core/map');
var paths = require('../core/paths');
var permissions = require('../core/permissions');
var posix = require('../../build/Release/posix');
Expand Down Expand Up @@ -184,12 +185,12 @@ var AppWorker = function(appSpec, endpoint, logStream, workerId, home) {
self.$proc = child_process.spawn(executable, args, {
stdio: ['pipe', 'pipe', logStream],
cwd: appSpec.appDir,
env: {
env: map.compact({
'RSTUDIO_PANDOC': paths.projectFile('ext/pandoc'),
'HOME' : home,
'LANG' : process.env['LANG'],
'PATH' : process.env['PATH']
},
}),
detached: true // So that we can send SIGINT not just to su but to the
// R process that it spawns as well
});
Expand Down

0 comments on commit 0b5c72d

Please sign in to comment.