#include #include void usage(void) { fprint(2, "usage: %s [-s sleep]\n", argv0); exits("usage"); } void main(int argc, char *argv[]) { char buf[8192]; long n; int b, ms; b = 1; ms = 10; ARGBEGIN { case 's': ms = atoi(EARGF(usage())); break; default: usage(); } ARGEND; if(b > sizeof buf) sysfatal("buffer size %d must be ≤ %d", b, sizeof buf); while((n=read(0, buf, b))>0) { sleep(ms); // assert b = n? if(write(1, buf, b) != b) sysfatal("error writing stdout: %r"); } if(n < 0) sysfatal("error reading stdin: %r"); exits(0); }