ProcessOutput (@NotNull ProgressIndicator indicator, int timeoutInMilliseconds, boolean destroyOnTimeout) { // keep in sync with runProcess if (timeoutInMilliseconds <= 0) { timeoutInMilliseconds = Integer.MAX_VALUE; } final int WAIT_INTERVAL = 10; int waitingTime = 0; boolean setExitCode = true; myProcessHandler.startNotify(); while (!myProcessHandler.waitFor(WAIT_INTERVAL)) { waitingTime += WAIT_INTERVAL; boolean timeout = waitingTime >= timeoutInMilliseconds; boolean canceled = indicator.isCanceled(); if (canceled || timeout) { boolean destroying = canceled || destroyOnTimeout; setExitCode = destroying; if (destroying && !myProcessHandler.isProcessTerminating() && !myProcessHandler.isProcessTerminated()) { myProcessHandler.destroyProcess(); } if (canceled) { myOutput.setCancelled(); } else { myOutput.setTimeout(); } break; } } if (setExitCode) { if (myProcessHandler.waitFor()) { setErrorCodeIfNotYetSet(); } else { LOG.info("runProcess: exit value unavailable"); } } return myOutput; }