add fastrecat
authorJann Horn <jann@thejh.net>
Sun, 24 Nov 2013 03:01:13 +0000 (04:01 +0100)
committerJann Horn <jann@thejh.net>
Sun, 24 Nov 2013 03:01:13 +0000 (04:01 +0100)
tools/fastrecat.c [new file with mode: 0644]

diff --git a/tools/fastrecat.c b/tools/fastrecat.c
new file mode 100644 (file)
index 0000000..ff57776
--- /dev/null
@@ -0,0 +1,19 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+  while (1) {
+    char buf[4096];
+    int fd = open(argv[1], O_RDONLY);
+    if (fd < 0) continue;
+    ssize_t s = read(fd, buf, 4096);
+    if (s>0) {
+      write(1, buf, s);
+    }
+    close(fd);
+    sched_yield();
+  }
+}