title: Start shell script in background from java program
body: <p>I currently start a shell script from my Java by code looking like this:</p>
  
  <pre><code>ProcessBuilder processBuilder = new ProcessBuilder();
  processBuilder.directory("/directory/where/the/script/is/located/");
  String[] command = new String[]{"sh", "myScript.sh"};
  processBuilder.command(command);
  Map&lt;String, String&gt; env = processBuilder.environment();
  //tweak the environment with needed additions
  env.put(...);
  Process p = processBuilder.start();
  
  stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
  stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
  
  // read the output from the command
  String line;
  while ((line = stdInput.readLine()) != null)
  {
    logger.fine(line);
  }
  p.waitFor();
  int returnCode = p.exitValue();
  // Return something according to the return code
  return ...;
  </code></pre>
  
  <p>If I now want to start the script and not wait for it to end (and thus losing the ability to return according to return code), but still with being able to tweak the environment beforehand? how should I proceed?</p>
  
  <p>Thank you</p>