private static void terminateProcessGracefully(int pid, @Nullable OutputStream processOutputStream) throws RuntimeException {
    if (SystemInfo.isWindows) {
      if (Registry.is("disable.winp")) {
        throw new UnsupportedOperationException("Cannot terminate process, disable.winp=true");
      }
      else {
        try {
          // there is no need to check return value: `sendCtrlC` either returns
          // true or throws exception.
          //noinspection ResultOfMethodCallIgnored
          ProcessService.getInstance().sendWinProcessCtrlC(pid, processOutputStream);
        }
        catch (Exception e) {
          throw new UnsupportedOperationException("Failed to terminate process", e);
        }
      }
    }
    else if (SystemInfo.isUnix) {
      UnixProcessManager.sendSignal(pid, UnixProcessManager.SIGINT);
    }
    else {
      throw new UnsupportedOperationException("Graceful termination is not supported for " + SystemInfo.getOsNameAndVersion());
    }
  }
private static void terminateProcessGracefully(int pid, @Nullable OutputStream processOutputStream)