@Override
  public void run() {
    // keep reading the InputStream until it ends (or an error occurs)
    try {
      String line;
      while ((line = reader.readLine()) != null) {
        if (writer != null) {
          writer.add(line);
        }
        if (listener != null) {
          listener.onLine(line);
        }
      }
    } catch (IOException e) {
      // reader probably closed, expected exit condition
    }

    // make sure our stream is closed and resources will be freed
    try {
      reader.close();
    } catch (IOException ignored) {
    }
  }
<p>StreamGobbler constructor</p>

<p>We use this class because shell STDOUT and STDERR should be read as quickly as possible to prevent a
deadlock from occurring, or Process.waitFor() never returning (as the buffer is full, pausing the native
process)</p>

@param inputStream
    InputStream to read from
@param onLineListener
    OnLineListener callback
imitate/src/main/java/com/engineer/imitate/shell/StreamGobbler.java