diff --git a/src/shell.js b/src/shell.js index b7a99d27c..c3df30b45 100644 --- a/src/shell.js +++ b/src/shell.js @@ -3,9 +3,7 @@ const assert = require('assert'), BoxError = require('./boxerror.js'), child_process = require('child_process'), - constants = require('./constants.js'), debug = require('debug')('box:shell'), - fs = require('fs'), once = require('./once.js'), util = require('util'); @@ -101,7 +99,6 @@ function sudo(tag, args, options, callback) { let sudoArgs = [ '-S' ]; // -S makes sudo read stdin for password if (options.preserveEnv) sudoArgs.push('-E'); // -E preserves environment if (options.ipc) sudoArgs.push('--close-from=4'); // keep the ipc open. requires closefrom_override in sudoers file - if (constants.TEST) options.logStream = fs.createWriteStream('/dev/null'); // without this output is messed up, not sure why const cp = spawn(tag, SUDO, sudoArgs.concat(args), options, callback); cp.stdin.end(); diff --git a/src/tasks.js b/src/tasks.js index a189fd35e..515fb94d8 100644 --- a/src/tasks.js +++ b/src/tasks.js @@ -45,8 +45,10 @@ exports = module.exports = { const assert = require('assert'), BoxError = require('./boxerror.js'), + constants = require('./constants.js'), database = require('./database.js'), debug = require('debug')('box:tasks'), + fs = require('fs'), logs = require('./logs.js'), path = require('path'), paths = require('./paths.js'), @@ -167,7 +169,9 @@ function startTask(id, options, callback) { let killTimerId = null, timedOut = false; - gTasks[id] = shell.sudo('startTask', [ START_TASK_CMD, id, logFile, options.nice || 0, options.memoryLimit || 400 ], { preserveEnv: true }, async function (sudoError) { + const sudoOptions = { preserveEnv: true, logStream: null }; + if (constants.TEST) sudoOptions.logStream = fs.createWriteStream('/dev/null'); // without this output is messed up, not sure why + gTasks[id] = shell.sudo('startTask', [ START_TASK_CMD, id, logFile, options.nice || 0, options.memoryLimit || 400 ], sudoOptions, async function (sudoError) { if (!gTasks[id]) return; // ignore task exit since we are shutting down. see stopAllTasks const code = sudoError ? sudoError.code : 0;