code: public static List<String> captureOutAndError(List<String> setup,
        List<String> cmd, 
        File stdoutFilename,
        File stderrFilename,
        long tailLength,
        boolean useSetsid
       ) throws IOException {
      List<String> result = new ArrayList<String>(3);
      result.add(bashCommand);
      result.add("-c");
      String mergedCmd = buildCommandLine(setup, cmd,
          stdoutFilename,
          stderrFilename, tailLength,
          useSetsid);
      result.add(mergedCmd.toString());
      return result; 
    }
docs: Wrap a command in a shell to capture stdout and stderr to files.
  Setup commands such as setting memory limit can be passed which
  will be executed before exec.
  If the tailLength is 0, the entire output will be saved.
  @param setup The setup commands for the execed process.
  @param cmd The command and the arguments that should be run
  @param stdoutFilename The filename that stdout should be saved to
  @param stderrFilename The filename that stderr should be saved to
  @param tailLength The length of the tail to be saved.
  @param useSetsid Should setsid be used in the command or not.
  @return the modified command that should be run