diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2011-02-07 10:59:29 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2011-02-07 10:59:29 +0100 |
commit | 9b1d91488f6b5c72b650bccf8ac7e2b668c69da7 (patch) | |
tree | f3a118da9a7177bc2a7bc6bc8c5fbe68d21079d9 | |
parent | 5e98825c8dca755eb70c93e32ae7743dee0a4f77 (diff) |
Only print error if there actually was one
write() returning 0 there is fine and not considered an error.
-rw-r--r-- | inotail.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; } |