code: public static void waitFor(Process proc, long timeout, TimeUnit unit) throws CommandTimeoutException {
  		try {
  			boolean finishedInTime = proc.waitFor(timeout, unit);
  			if (!finishedInTime) {
  				proc.destroyForcibly();
  				throw new CommandTimeoutException();
  			}
  		} catch (InterruptedException e) {
  			Thread.currentThread().interrupt();
  		}
  	}
docs: Waits for the process to terminate or throws an exception if it fails to do so within the given timeout.
  
  @param proc A started process
  @param timeout Maximum time to wait
  @param unit Time unit of <code>timeout</code>
  @throws CommandTimeoutException Thrown in case of a timeout