void (@NotNull final ProcessEvent event) { try { final RemoteOutputReader stdoutReader = new RemoteOutputReader(myProcess.getInputStream(), getCharset(), myProcess, myCommandLine, readerOptions()) { @Override protected void onTextAvailable(@NotNull String text) { notifyTextAvailable(text, ProcessOutputTypes.STDOUT); } @NotNull @Override protected Future<?> executeOnPooledThread(@NotNull Runnable runnable) { return BaseRemoteProcessHandler.this.executeTask(runnable); } }; final RemoteOutputReader stderrReader = new RemoteOutputReader(myProcess.getErrorStream(), getCharset(), myProcess, myCommandLine, readerOptions()) { @Override protected void onTextAvailable(@NotNull String text) { notifyTextAvailable(text, ProcessOutputTypes.STDERR); } @NotNull @Override protected Future<?> executeOnPooledThread(@NotNull Runnable runnable) { return BaseRemoteProcessHandler.this.executeTask(runnable); } }; myWaitFor.setTerminationCallback(exitCode -> { try { try { stderrReader.waitFor(); stdoutReader.waitFor(); } catch (InterruptedException ignore) { } } finally { onOSProcessTerminated(exitCode); } }); } finally { removeProcessListener(this); } }