summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2011-02-07 10:59:29 +0100
committerTobias Klauser <tklauser@distanz.ch>2011-02-07 10:59:29 +0100
commit9b1d91488f6b5c72b650bccf8ac7e2b668c69da7 (patch)
treef3a118da9a7177bc2a7bc6bc8c5fbe68d21079d9
parent5e98825c8dca755eb70c93e32ae7743dee0a4f77 (diff)
Only print error if there actually was one
write() returning 0 there is fine and not considered an error.
-rw-r--r--inotail.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/inotail.c b/inotail.c
index d1c30d5..9d79d01 100644
--- a/inotail.c
+++ b/inotail.c
@@ -421,13 +421,15 @@ static int tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
if ((rc = write(STDOUT_FILENO, p, tmp->buf + tmp->n_bytes - p)) <= 0) {
/* e.g. when writing to a pipe which gets closed */
- fprintf(stderr, "Error: Could not write to stdout (%s)\n", strerror(errno));
+ if (rc)
+ fprintf(stderr, "Error: Could not write to stdout (%s)\n", strerror(errno));
goto out;
}
for (tmp = tmp->next; tmp; tmp = tmp->next)
if ((rc = write(STDOUT_FILENO, tmp->buf, tmp->n_bytes)) <= 0) {
- fprintf(stderr, "Error: Could not write to stdout (%s)\n", strerror(errno));
+ if (rc)
+ fprintf(stderr, "Error: Could not write to stdout (%s)\n", strerror(errno));
goto out;
}