void PosixSpawnIORedirector::ConsumeAllSubprocessOutput()

in tools/common/process.cc [102:119]


void PosixSpawnIORedirector::ConsumeAllSubprocessOutput(
    std::ostream *stderr_stream) {
  SafeClose(&stderr_pipe_[1]);

  char stderr_buffer[1024];
  pollfd stderr_poll = {stderr_pipe_[0], POLLIN};
  int status;
  while ((status = poll(&stderr_poll, 1, -1)) > 0) {
    if (stderr_poll.revents) {
      int bytes_read =
          read(stderr_pipe_[0], stderr_buffer, sizeof(stderr_buffer));
      if (bytes_read == 0) {
        break;
      }
      stderr_stream->write(stderr_buffer, bytes_read);
    }
  }
}