void (final @NotNull ProcessEvent event) { try { BaseDataReader stdOutReader = createOutputDataReader(); BaseDataReader stdErrReader = processHasSeparateErrorStream() ? createErrorDataReader() : null; myWaitFor.setTerminationCallback(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); } }