/* Sample of creating a pipe and using it within a single process. This example creates a pipe, then writes until write returns an error (trying to find out how much a pipe can hold) */ #include #include #include #include #include #include /* here is the actual data sent to the pipe: */ #define BUFSIZE 1024 int main(int argc, char **argv) { int fds[2]; char data[BUFSIZE]; int n; unsigned int tot; /* attempt to create a pipe */ if (pipe(fds)<0) { perror("Fatal Error"); exit(1); } while (write(fds[1],data,BUFSIZE)>0) { tot += BUFSIZE; if (tot & 0x0FFFF) { printf("%u\n",tot); } } printf("Final tally %u\n",tot); return(0); }