void (@Nullable ProcessHandler processHandler) { if (processHandler != null) { processHandler.addProcessListener(new ProcessAdapter() { @Override public void processWillTerminate(@NotNull ProcessEvent event, boolean willBeDestroyed) { if (!willBeDestroyed) { // always terminate forked process terminateForkedProcess(event.getProcessHandler()); } } }); } }