private static int launchProcess(ProcessBuilder builder) throws Exception {
    int exitCode = -1;
    Process process = null;
    try {
      process = builder.start();
      exitCode = process.waitFor();
    } catch (Exception ioe) {
      String message = "Error executing Service Advisor: ";
      LOG.error(message, ioe);
      throw new Exception(message + ioe.getMessage());
    } finally {
      if (process != null) {
        process.destroy();
      }
    }
    return exitCode;
  }
Launch a process, wait for it to finish, and return its exit code.
@param builder Process Builder
@return Exit Code
@throws Exception
ambari-serviceadvisor/src/main/java/org/apache/ambari/serviceadvisor/ServiceAdvisor.java