private void stopForkedProcessWhenMainProcessTerminated(@Nullable ProcessHandler processHandler) {
    if (processHandler != null) {
      myMainProcessHandler.addProcessListener(new ProcessAdapter() {
        @Override
        public void processWillTerminate(@NotNull ProcessEvent event, boolean willBeDestroyed) {
          myMainProcessHandler.removeProcessListener(this);
          terminateForkedProcess(processHandler);
        }
      });
    }
  }
private void stopForkedProcessWhenMainProcessTerminated(@Nullable ProcessHandler processHandler)