diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2007-06-12 18:31:12 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@xenon.tklauser.home> | 2007-06-12 18:31:12 +0200 |
commit | 82ffa4b8fcfdcd4ec98563daa06ec135f66ad181 (patch) | |
tree | 58d6d53ece6b1c85261b9c6d4bcee84e4d5dc858 | |
parent | b50204eabab7a2f5f21f12e5668f7c8d954aa84a (diff) |
inotail.c: Handle EINTR and EAGAIN in tail_pipe_lines()
-rw-r--r-- | inotail.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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; } |