[PATCHv3 02/11] run-command: report failure for degraded output just once
- From
Stefan Beller <sbeller@google.com>
- Date
- Nov 4, 2015, 00:37 UTC
- Message-ID
- <1446597434-1740-3-git-send-email-sbeller@google.com>
- In-Reply-To
- <1446597434-1740-1-git-send-email-sbeller@google.com>
The warning message is cluttering the output itself, so just report it once.
Signed-off-by: Stefan Beller <sbeller@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