Here you can find the source of waitForProcess(Process process, String name)
public static int waitForProcess(Process process, String name) throws RuntimeException
//package com.java2s; //License from project: Apache License import java.util.concurrent.TimeUnit; public class Main { private static final int KILL_TIMEOUT = 20000; public static int waitForProcess(Process process, String name) throws RuntimeException { return waitForProcess(process, name, true); }/*from w w w .j a va 2 s. c o m*/ public static int waitForProcess(Process process, String name, boolean throwError) throws RuntimeException { boolean finished = false; try { finished = process.waitFor(KILL_TIMEOUT, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { /* do nothing */} if (!finished) { throw new RuntimeException(name + " subprocess terminated."); } else if (process.exitValue() != 0) { if (throwError) { throw new RuntimeException(name + " subprocess failed: " + process.exitValue()); } } return process.exitValue(); } }