code: public void processWithHandler(ProcessHandler handler) {
      Process process = null;
      try
      {
        process = startImpl();
        ShellProcess shellProcess = new ShellProcess(process);
        handler.run(shellProcess);
        try {
          process.exitValue();
        } catch (IllegalThreadStateException e) {
          // Process not yet dead so kill
          process.destroy();
        }
      }
      catch( IOException e )
      {
        throw new RuntimeException( e );
      } finally {
        if (process != null) {
          // close all three streams.
          try {
            process.getErrorStream().close();
          } catch ( IOException e) {
            e.printStackTrace();
          }
          try {
            process.getInputStream().close();
          } catch( IOException e ) {
            e.printStackTrace();
          }
          try {
            process.getOutputStream().close();
          } catch( IOException e ) {
            e.printStackTrace();
          }
        }
      }
    }
docs: <p>Executes the given command as if it had been executed from the command line of the host OS
  (cmd.exe on windows, /bin/sh on *nix) and calls the provided handler with the newly created process.
  
  <p><b>NOTE:</b> In gosu, you should take advantage of the block-to-interface coercion provided and pass
  blocks in as the handler.  See the examples below.</p>
  </p>
  
  @param handler the process handler for this process.