#include #include #include int main(int argc, char **argv) { int pipe_ends [2]; if (pipe(pipe_ends) == -1) perror("pipe"), exit(1); char msg [] = { "Hi\n" }; if (write(pipe_ends[1], msg, sizeof msg - 1) == -1) perror("write"); close(pipe_ends[1]); char pipe_buf[128]; size_t n; while ((n = read(pipe_ends[0], pipe_buf, sizeof pipe_buf)) > 0) if (write(1, pipe_buf, n) != n) perror("write"); }