Blob Blame History Raw
From f59664a01fa9b525e211fbcb837bf8b54cac9acb Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 16 Aug 2018 11:14:11 +0200
Subject: [PATCH] logtee: reduce output

---
 logtee.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/logtee.c b/logtee.c
index 2f1937d4..2690e72d 100644
--- a/logtee.c
+++ b/logtee.c
@@ -6,6 +6,8 @@
 #include <errno.h>
 #include <limits.h>
 
+#define BUFLEN 4096
+
 int
 main(int argc, char *argv[])
 {
@@ -25,9 +27,11 @@ main(int argc, char *argv[])
 
 	fprintf(stderr, "Logging to %s: ", argv[1]);
 
+	slen = 0;
+
 	do {
 		len = splice(STDIN_FILENO, NULL, fd, NULL,
-			     65536, SPLICE_F_MOVE);
+			     BUFLEN, SPLICE_F_MOVE);
 
 		if (len < 0) {
 			if (errno == EAGAIN)
@@ -37,10 +41,14 @@ main(int argc, char *argv[])
 		} else
 			if (len == 0)
 				break;
-		fprintf(stderr, ".", len);
+		slen += len;
+		if ((slen/BUFLEN) > 0) {
+			fprintf(stderr, ".");
+		}
+		slen = slen % BUFLEN;
+
 	} while (1);
 	close(fd);
 	fprintf(stderr, "\n");
 	exit(EXIT_SUCCESS);
-}
-
+}
\ No newline at end of file