public void run(){
  stdout="";
  stderr="";
  exitValue=-1;
  error=null;
  timedout=false;
  succeeded=false;
  try {
    ProcessBuilder pb=new ProcessBuilder(commands);
    Map<String,String> localEnv=pb.environment();
    for (    String key : env.keySet()) {
      localEnv.put(key,env.get(key));
    }
    pb.directory(workDirectory);
    pb.redirectErrorStream(redirectStdErr);
    process=pb.start();
    exitValue=handleProcessIO(process);
  }
 catch (  InterruptedException e) {
    logger.warn("Command timed out: command=" + commandsToString(commands) + " timeout="+ timeout);
    timedout=true;
  }
catch (  IOException e) {
    logger.warn("Command failed with I/O error: command=" + commandsToString(commands));
    logger.debug("Command I/O exception: " + e);
    error=e;
  }
catch (  Throwable e) {
    logger.warn("Command failed with unexpected exception: command=" + commandsToString(commands),e);
    error=e;
  }
  if (this.error != null)   succeeded=false;
 else   if (this.exitValue != 0)   succeeded=false;
 else   if (this.timedout == true)   succeeded=false;
 else   succeeded=true;
}

public void run ( ) { stdout = "" ; stderr = "" ; exitValue = - 1 ; error = null ; timedout = false ; succeeded = false ; try { ProcessBuilder pb = new ProcessBuilder ( commands ) ; Map < String , String > localEnv = pb . environment ( ) ; for ( String key : env . keySet ( ) ) { localEnv . put ( key , env . get ( key ) ) ; } pb . directory ( workDirectory ) ; pb . redirectErrorStream ( redirectStdErr ) ; process = pb . start ( ) ; exitValue = handleProcessIO ( process ) ; } catch ( InterruptedException e ) { logger . warn ( "Command timed out: command=" + commandsToString ( commands ) + " timeout=" + timeout ) ; timedout = true ; } catch ( IOException e ) { logger . warn ( "Command failed with I/O error: command=" + commandsToString ( commands ) ) ; logger . debug ( "Command I/O exception: " + e ) ; error = e ; } catch ( Throwable e ) { logger . warn ( "Command failed with unexpected exception: command=" + commandsToString ( commands ) , e ) ; error = e ; } if ( this . error != null ) succeeded = false ; else if ( this . exitValue != 0 ) succeeded = false ; else if ( this . timedout == true ) succeeded = false ; else succeeded = true ; }
execute the command . when this method returns it is safe for callers to read output values .
