10 #include "includes/pipe_reader.h"
12 pipe_reader::pipe_reader(int pipe_fd) : pipe_fd_(pipe_fd) {
13 // add O_NONBLOCK TO fd's flags to be able to read
14 auto flags = fcntl(pipe_fd_, F_GETFL, 0);
16 fcntl(pipe_fd_, F_SETFL, flags);
19 size_t pipe_reader::read(std::vector<std::string::value_type>& buffer) const {
20 ssize_t rv = ::read(pipe_fd_, buffer.data(), buffer.size());
27 // TODO: introduce custom subprocess_error
28 throw std::runtime_error{"unexpected error reading from pipe: " + std::string(strerror(errno))};