private String doStty(String sttyOptionsString) {
    String[] cmd = { "/bin/sh", "-c", "stty " + sttyOptionsString + " < /dev/tty" };

    try {
      Process process = Runtime.getRuntime().exec(cmd);

      String ret;

      // stdout
      try (BufferedReader stdout = new BufferedReader(
        new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) {
        ret = stdout.readLine();
      }

      // stderr
      try (BufferedReader stderr = new BufferedReader(
        new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8))) {
        String line = stderr.readLine();
        if ((line != null) && (line.length() > 0)) {
          LOGGER.error("Error output from stty: " + line);
        }
      }

      try {
        process.waitFor();
      } catch (InterruptedException e) {
        // Restore interrupt status
        Thread.currentThread().interrupt();
      }

      int exitValue = process.exitValue();
      if (exitValue != 0) {
        LOGGER.error("stty returned error code: " + exitValue);
      }
      return ret;
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
  }
An implementation of the {@link Terminal} interface for normal display mode. This implementation
produces output intended for human viewing. In particular, it only displays one screenful of
data. The output contains some escape sequences for formatting.
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/terminal/impl/TerminalImpl.java