summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2008-11-14 15:12:39 +0100
committerTobias Klauser <tklauser@xenon.tklauser.home>2008-11-14 15:12:39 +0100
commit0a02ab4945c5cf65e305319e2c1ea49d4dbe3a97 (patch)
tree33511cec6ae17845873b80d037252c59dfd2f70f
parenta1b82a30dc7133b4fbcaa132ce5ef85c4771aafc (diff)
More comments and clearify a return statement.
-rw-r--r--inotail.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/inotail.c b/inotail.c
index 62920ba..000b5c1 100644
--- a/inotail.c
+++ b/inotail.c
@@ -158,7 +158,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 */
}
}
}
@@ -248,6 +248,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
@@ -268,6 +269,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 {