#include #include int main(){ // make a pipe int pipe_fds[2]; // read end is pipe_fds[0], write end is pipe_fds[1] pipe(pipe_fds); // put something into the pipe write(pipe_fds[1], "snake", 5); write(pipe_fds[1], "lemon", 6); // This one adds a null terminator // read it back out of the pipe char buffer[16] = "aaaaaaaaaaaaaaaa"; read(pipe_fds[0], buffer, 16); printf("Read \"%s\" from the pipe\n", buffer); for(int i = 0; i < 100; i++) // Hangs with i < 100000 write(pipe_fds[1], "spider", 6); char big_buffer[1024*1024]; read(pipe_fds[0], big_buffer, 1024*1024); printf("Read %s from the pipe\n", big_buffer); return 0; }