private static int processFile(String fileName) throws IOException {
    FileReader fileReader = null;
    BufferedReader reader = null;
    try {
      fileReader = new FileReader(fileName);
      reader = new BufferedReader(fileReader);
      String line;
      StringBuilder qsb = new StringBuilder();

      while ((line = reader.readLine()) != null) {
        qsb.append(line + "\n");
      }

      return (processLine(qsb.toString()));
    } finally {
      if (fileReader != null) {
        fileReader.close();
      }
      if (reader != null) {
        reader.close();
      }
    }
  }
Wrapper for System.exit that makes sure we close our SessionState
before we exit. This ignores any error generated by attempting to
close the session state, merely printing out the error. The return
code is not changed in such an occurrence because we want to retain
the success code of whatever command we already ran.
hcatalog/core/src/main/java/org/apache/hive/hcatalog/cli/HCatCli.java