Created
October 20, 2011 05:23
-
-
Save apk/1300486 to your computer and use it in GitHub Desktop.
Pipe slowed down to 200 cps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main () { | |
int f = 0; | |
int w; | |
char buf [1024]; | |
while (1) { | |
int r = read (0, buf, sizeof (buf)); | |
if (r <= 0) break; | |
if (r < sizeof (buf)) { | |
f = 1; | |
} | |
for (w = 0; w < r; ) { | |
int x = r - w; | |
if (x > 2) x = 2; | |
x = write (1, buf + w, x); | |
if (x <= 0) break; | |
w += x; | |
if (f) usleep (5000 * x); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment