The warning message is cluttering the output itself,
so just report it once.

Signed-off-by: Stefan Beller <sbel...@google.com>
---
 run-command.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/run-command.c b/run-command.c
index 7c00c21..3ae563f 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1012,13 +1012,21 @@ static void pp_cleanup(struct parallel_processes *pp)
 
 static void set_nonblocking(int fd)
 {
+       static int reported_degrade = 0;
        int flags = fcntl(fd, F_GETFL);
-       if (flags < 0)
-               warning("Could not get file status flags, "
-                       "output will be degraded");
-       else if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
-               warning("Could not set file status flags, "
-                       "output will be degraded");
+       if (flags < 0) {
+               if (!reported_degrade) {
+                       warning("Could not get file status flags, "
+                               "output will be degraded");
+                       reported_degrade = 1;
+               }
+       } else if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
+               if (!reported_degrade) {
+                       warning("Could not set file status flags, "
+                               "output will be degraded");
+                       reported_degrade = 1;
+               }
+       }
 }
 
 /* returns
-- 
2.6.1.247.ge8f2a41.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to