summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inotail.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/inotail.c b/inotail.c
index 2676176..fdb2919 100644
--- a/inotail.c
+++ b/inotail.c
@@ -322,14 +322,17 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines)
}
}
- write(STDOUT_FILENO, p, tmp->buf + tmp->n_bytes - p);
+ 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));
+ goto out;
+ }
for (tmp = tmp->next; tmp; tmp = tmp->next)
- if (write(STDOUT_FILENO, tmp->buf, tmp->n_bytes) <= 0) {
+ if ((rc = write(STDOUT_FILENO, tmp->buf, tmp->n_bytes)) <= 0) {
/* e.g. when writing to a pipe which gets closed */
fprintf(stderr, "Error: Could not write to stdout (%s)\n", strerror(errno));
- rc = -1;
- break;
+ goto out;
}
rc = 0;