| 14 | #include <stdio.h> |
| 15 | |
| 16 | static bool |
| 17 | Copy(OutputStream &dest, int src) |
| 18 | { |
| 19 | while (true) { |
| 20 | std::byte buffer[8192]; |
| 21 | ssize_t nbytes = read(src, buffer, sizeof(buffer)); |
| 22 | if (nbytes < 0) { |
| 23 | fprintf(stderr, "Failed to read from stdin: %s\n", |
| 24 | strerror(errno)); |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | if (nbytes == 0) |
| 29 | return true; |
| 30 | |
| 31 | dest.Write(std::span{buffer}.first(nbytes)); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | int |
| 36 | main(int argc, char **argv) |