1 // A small "cat" utility that copies stdin to stdout.
2 // It does only one 4K read from stdin, and writes it to stdout in as few
3 // write()s as possible.
4 // This gives a controlled number of operations, which makes testing the
5 // random operations more robust.
7 #include <stdio.h> // printf(), perror()
8 #include <unistd.h> // read(), write()
10 const size_t BUFSIZE
= 4092;
17 r
= read(0, buf
, BUFSIZE
);
19 perror("Read error in small-cat");
25 w
= write(1, buf
+ pos
, r
);
27 perror("Write error in small-cat");