summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2007-06-12 18:31:12 +0200
committerTobias Klauser <tklauser@xenon.tklauser.home>2007-06-12 18:31:12 +0200
commit82ffa4b8fcfdcd4ec98563daa06ec135f66ad181 (patch)
tree58d6d53ece6b1c85261b9c6d4bcee84e4d5dc858
parentb50204eabab7a2f5f21f12e5668f7c8d954aa84a (diff)
inotail.c: Handle EINTR and EAGAIN in tail_pipe_lines()
-rw-r--r--inotail.c10
1 files 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;
}