summaryrefslogtreecommitdiff
path: root/inotail.c
diff options
context:
space:
mode:
Diffstat (limited to 'inotail.c')
-rw-r--r--inotail.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/inotail.c b/inotail.c
index b61e30a..2fa7017 100644
--- a/inotail.c
+++ b/inotail.c
@@ -173,7 +173,7 @@ static off_t lines_to_offset_from_end(struct file_struct *f, unsigned long n_lin
if (buf[i] == '\n') {
if (--n_lines == 0) {
free(buf);
- return offset += i + 1; /* We don't want the first \n */
+ return offset + i + 1; /* We don't want the first \n */
}
}
}
@@ -263,6 +263,7 @@ static int tail_pipe_from_begin(struct file_struct *f, unsigned long n_units, co
while (n_units > 0) {
if ((bytes_read = read(f->fd, buf, BUFSIZ)) <= 0) {
+ /* Interrupted by a signal, retry reading */
if (bytes_read < 0 && (errno == EINTR || errno == EAGAIN))
continue;
else
@@ -283,6 +284,7 @@ static int tail_pipe_from_begin(struct file_struct *f, unsigned long n_units, co
}
}
+ /* Print remainder of the current block */
if (++i < block_size)
write(STDOUT_FILENO, &buf[i], bytes_read - i);
} else {
@@ -619,7 +621,7 @@ static int handle_inotify_event(struct inotify_event *inev, struct file_struct *
}
/* Seek to old file size */
- if ((ret = lseek(f->fd, f->size, SEEK_SET)) == (off_t) -1) {
+ if (!IS_PIPELIKE(finfo.st_mode) && (ret = lseek(f->fd, f->size, SEEK_SET)) == (off_t) -1) {
fprintf(stderr, "Error: Could not seek in file '%s' (%s)\n", f->name, strerror(errno));
goto ignore;
}