}
}
private ExecBean auxRun(String program, List<String> args, Map<String, String> env)
throws NotAuthorizedException, ExecuteException, IOException {
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValues(null);
// Setup stdout and stderr
int nbytes = appConf.getInt(AppConfig.EXEC_MAX_BYTES_NAME, -1);
ByteArrayOutputStream outStream = new MaxByteArrayOutputStream(nbytes);
ByteArrayOutputStream errStream = new MaxByteArrayOutputStream(nbytes);
executor.setStreamHandler(new PumpStreamHandler(outStream, errStream));
// Only run for N milliseconds
int timeout = appConf.getInt(AppConfig.EXEC_TIMEOUT_NAME, 0);
ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
executor.setWatchdog(watchdog);
CommandLine cmd = makeCommandLine(program, args);
LOG.info("Running: " + cmd);
ExecBean res = new ExecBean();
res.exitcode = executor.execute(cmd, execEnv(env));
String enc = appConf.get(AppConfig.EXEC_ENCODING_NAME);
res.stdout = outStream.toString(enc);
res.stderr = errStream.toString(enc);
return res;