code: public static void stopProcessOnShutdown(final Process process) {
      Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        try {
          process.stop();
        } catch (Throwable t) {
          LOG.error("Failed to stop process", t);
        }
      }, "alluxio-process-shutdown-hook"));
    }
docs: Adds a shutdown hook that will be invoked when a signal is sent to this process.
  
  The process may be utilizing some resources, and this shutdown hook will be invoked by
  JVM when a SIGTERM is sent to the process by "kill" command. The shutdown hook calls
  {@link Process#stop()} method to cleanly release the resources and exit.
  
  @param process the data structure representing the process to terminate