Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE /* See feature_test_macros(7) */
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <assert.h>
- int main(int argc, char ** argv) {
- const int bs = 4096;
- unsigned char buf[bs];
- for (int i = 0; i < bs; i+=2) {
- buf[i] = 'y';
- buf[i+1] = '\n';
- }
- int p[2];
- assert(pipe(p) == 0);
- int r = fcntl(p[1], F_SETPIPE_SZ, bs);
- fprintf(stderr, "bs %d r %d\n", bs, r);
- assert(r >= bs);
- assert(write(p[1], buf, bs) == bs);
- while (1) {
- int z = tee(p[0], STDOUT_FILENO, bs, 0);
- if (z != bs) {
- fprintf(stderr, "z %d bs %d\n", z, bs);
- }
- assert(z == bs);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment