diff options
-rw-r--r-- | inotail.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; |