code: public static void waitForProcessOutput(Process self, Appendable output, Appendable error) {
          Thread tout = consumeProcessOutputStream(self, output);
          Thread terr = consumeProcessErrorStream(self, error);
          try { tout.join(); } catch (InterruptedException ignore) {}
          try { terr.join(); } catch (InterruptedException ignore) {}
          try { self.waitFor(); } catch (InterruptedException ignore) {}
          closeStreams(self);
      }
docs: Gets the output and error streams from a process and reads them
  to keep the process from blocking due to a full output buffer.
  The processed stream data is appended to the supplied Appendable.
  For this, two Threads are started, but join()ed, so we wait.
  As implied by the waitFor... name, we also wait until we finish
  as well. Finally, the input, output and error streams are closed.
  
  @param self a Process
  @param output an Appendable to capture the process stdout
  @param error an Appendable to capture the process stderr
  @since 1.7.5