// Start a process to run the command
Process pr = Runtime.getRuntime().exec(serverCmd);
// TimedProcess, kill process if process doesnt finish in a certain
// amount of time
TimedProcess tp = new TimedProcess(pr);
prout = new ProcessStreamResult(pr.getInputStream(), bos,
timeoutMinutes);
prerr = new ProcessStreamResult(pr.getErrorStream(), bos,
timeoutMinutes);
// wait until all the results have been processed
boolean outTimedOut = prout.Wait();
boolean errTimedOut = prerr.Wait();
// wait for this process to terminate, upto a wait period
// of 'timeoutSecondsForProcess'
// if process has already been terminated, this call will
// return immediately.
tp.waitFor(timeoutSecondsForProcess);
pr = null;
if (outTimedOut || errTimedOut)
System.out.println(" Reading from process streams timed out.. ");