From 82ffa4b8fcfdcd4ec98563daa06ec135f66ad181 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 12 Jun 2007 18:31:12 +0200 Subject: inotail.c: Handle EINTR and EAGAIN in tail_pipe_lines() --- inotail.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inotail.c b/inotail.c index e98a881..912db03 100644 --- a/inotail.c +++ b/inotail.c @@ -246,8 +246,12 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines) while (1) { const char *p; - if ((rc = read(f->fd, tmp->buf, BUFFER_SIZE)) <= 0) - break; + if ((rc = read(f->fd, tmp->buf, BUFFER_SIZE)) <= 0) { + if (rc < 0 && (errno == EINTR || errno == EAGAIN)) + continue; + else + break; + } tmp->n_bytes = rc; tmp->n_lines = 0; tmp->next = NULL; @@ -280,10 +284,8 @@ static ssize_t tail_pipe_lines(struct file_struct *f, unsigned long n_lines) free(tmp); - /* XXX: Even necessary? */ if (rc < 0) { fprintf(stderr, "Error: Could not read from %s\n", pretty_name(f->name)); - rc = -1; goto err_out; } -- cgit v1.2.3-54-g00ecf