public Process exec(String[] taintedCommand,String[] taintedEnvironment,File workingDirectory,boolean redirectErrorStream) throws IOException {
  if (taintedCommand == null) {
    throw new NullPointerException("taintedCommand == null");
  }
  if (taintedCommand.length == 0) {
    throw new IndexOutOfBoundsException("taintedCommand.length == 0");
  }
  String[] command=taintedCommand.clone();
  String[] environment=taintedEnvironment != null ? taintedEnvironment.clone() : null;
  for (int i=0; i < command.length; i++) {
    if (command[i] == null) {
      throw new NullPointerException("taintedCommand[" + i + "] == null");
    }
  }
  if (environment != null) {
    for (int i=0; i < environment.length; i++) {
      if (environment[i] == null) {
        throw new NullPointerException("taintedEnvironment[" + i + "] == null");
      }
    }
  }
  FileDescriptor in=new FileDescriptor();
  FileDescriptor out=new FileDescriptor();
  FileDescriptor err=new FileDescriptor();
  String workingPath=(workingDirectory == null) ? null : workingDirectory.getPath();
synchronized (processReferences) {
    int pid;
    try {
      pid=exec(command,environment,workingPath,in,out,err,redirectErrorStream);
    }
 catch (    IOException e) {
      IOException wrapper=new IOException("Error running exec()." + " Command: " + Arrays.toString(command) + " Working Directory: "+ workingDirectory+ " Environment: "+ Arrays.toString(environment));
      wrapper.initCause(e);
      throw wrapper;
    }
    ProcessImpl process=new ProcessImpl(pid,in,out,err);
    ProcessReference processReference=new ProcessReference(process,referenceQueue);
    processReferences.put(pid,processReference);
    processReferences.notifyAll();
    return process;
  }
}

public Process exec ( String [ ] taintedCommand , String [ ] taintedEnvironment , File workingDirectory , boolean redirectErrorStream ) throws IOException { if ( taintedCommand == null ) { throw new NullPointerException ( "taintedCommand == null" ) ; } if ( taintedCommand . length == 0 ) { throw new IndexOutOfBoundsException ( "taintedCommand.length == 0" ) ; } String [ ] command = taintedCommand . clone ( ) ; String [ ] environment = taintedEnvironment != null ? taintedEnvironment . clone ( ) : null ; for ( int i = 0 ; i < command . length ; i ++ ) { if ( command [ i ] == null ) { throw new NullPointerException ( "taintedCommand[" + i + "] == null" ) ; } } if ( environment != null ) { for ( int i = 0 ; i < environment . length ; i ++ ) { if ( environment [ i ] == null ) { throw new NullPointerException ( "taintedEnvironment[" + i + "] == null" ) ; } } } FileDescriptor in = new FileDescriptor ( ) ; FileDescriptor out = new FileDescriptor ( ) ; FileDescriptor err = new FileDescriptor ( ) ; String workingPath = ( workingDirectory == null ) ? null : workingDirectory . getPath ( ) ; synchronized ( processReferences ) { int pid ; try { pid = exec ( command , environment , workingPath , in , out , err , redirectErrorStream ) ; } catch ( IOException e ) { IOException wrapper = new IOException ( "Error running exec()." + " Command: " + Arrays . toString ( command ) + " Working Directory: " + workingDirectory + " Environment: " + Arrays . toString ( environment ) ) ; wrapper . initCause ( e ) ; throw wrapper ; } ProcessImpl process = new ProcessImpl ( pid , in , out , err ) ; ProcessReference processReference = new ProcessReference ( process , referenceQueue ) ; processReferences . put ( pid , processReference ) ; processReferences . notifyAll ( ) ; return process ; } }
executes a process and returns an object representing it .
