Improve the pipe API

This commit is contained in:
Victor Zverovich
2024-01-01 15:55:37 -08:00
parent 398ddb8fec
commit c142385033
9 changed files with 111 additions and 132 deletions
+3 -3
View File
@@ -17,10 +17,10 @@ output_redirect::output_redirect(FILE* f, bool flush) : file_(f) {
// Create a file object referring to the original file.
original_ = file::dup(fd);
// Create a pipe.
file write_end;
file::pipe(read_end_, write_end);
auto pipe = fmt::pipe();
read_end_ = std::move(pipe.read_end);
// Connect the passed FILE object to the write end of the pipe.
write_end.dup2(fd);
pipe.write_end.dup2(fd);
}
output_redirect::~output_redirect() noexcept {