From af744d73bf274eea9c8ae6fbb34d0a136777ce2f Mon Sep 17 00:00:00 2001 From: rofl0r Date: Thu, 16 Feb 2017 22:00:46 +0000 Subject: [PATCH] add stdin_printer test --- tests/stdin_printer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/stdin_printer.c diff --git a/tests/stdin_printer.c b/tests/stdin_printer.c new file mode 100644 index 0000000..d6813ef --- /dev/null +++ b/tests/stdin_printer.c @@ -0,0 +1,17 @@ +/* like cat, but processing one line at a time. stdin only. */ +#include +#include +#include + +int main() { + char buf[1024]; + while(fgets(buf, sizeof buf, stdin)) { + ssize_t l = strlen(buf); + ssize_t n = write(1, buf, l); + if(n != l) { + perror("write"); + return 1; + } + } + return 0; +} -- 2.11.4.GIT