@Override public void startNotify() { if (myCommandLine != null) { notifyTextAvailable(myCommandLine + '\n', ProcessOutputTypes.SYSTEM); } addProcessListener(new ProcessAdapter() { @Override public void startNotified(final ProcessEvent event) { try { BaseOutputReader.SleepingPolicy sleepingPolicy = useAdaptiveSleepingPolicyWhenReadingOutput() ? new AdaptiveSleepingPolicy() : BaseOutputReader.SleepingPolicy.SIMPLE; final BaseOutputReader stdoutReader = new SimpleOutputReader(createProcessOutReader(), ProcessOutputTypes.STDOUT, sleepingPolicy); final BaseOutputReader stderrReader = processHasSeparateErrorStream() ? new SimpleOutputReader(createProcessErrReader(), ProcessOutputTypes.STDERR, sleepingPolicy) : null; myWaitFor.setTerminationCallback(new Consumer<Integer>() { @Override public void consume(Integer exitCode) { try { // tell readers that no more attempts to read process' output should be made if (stderrReader != null) stderrReader.stop(); stdoutReader.stop(); try { if (stderrReader != null) stderrReader.waitFor(); stdoutReader.waitFor(); } catch (InterruptedException ignore) { } } finally { onOSProcessTerminated(exitCode); } } }); } finally { removeProcessListener(this); } } }); super.startNotify(); }
@Nonnull @Override protected BaseOutputReader.Options readerOptions() { return myHasPty ? BaseOutputReader.Options.BLOCKING : super.readerOptions(); // blocking read in case of PTY-based process }
@Nonnull @Override protected BaseOutputReader.Options readerOptions() { return READER_OPTIONS; }