#include "unique_pipe.hh" #include #include unique_pipe::unique_pipe() { int fd[2]; if (pipe(fd)) return; fd_[0] = unique_fd(fd[0]); fd_[1] = unique_fd(fd[1]); } unique_pipe::unique_pipe(unique_pipe&& fd) { fd_[0] = unique_fd(fd.fd_[0].release()); fd_[1] = unique_fd(fd.fd_[1].release()); } unique_pipe& unique_pipe::operator=(unique_pipe&& fd) { fd_[0].reset(fd.fd_[0].release()); fd_[1].reset(fd.fd_[1].release()); return *this; } void unique_pipe::reset() { fd_[0].reset(); fd_[1].reset(); } unique_fd unique_pipe::release_reader() { return std::move(fd_[0]); } unique_fd unique_pipe::release_writer() { return std::move(fd_[1]); }