summaryrefslogtreecommitdiff
path: root/inotail.c
diff options
context:
space:
mode:
Diffstat (limited to 'inotail.c')
-rw-r--r--inotail.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/inotail.c b/inotail.c
index 3e326fa..bdabe9a 100644
--- a/inotail.c
+++ b/inotail.c
@@ -103,13 +103,13 @@ static off_t lines_to_offset(int fd, int file_size, unsigned int n_lines)
static int tail_file(struct file_struct *f, int n_lines)
{
- int fd, rc;
+ int fd;
+ ssize_t rc = 0;
off_t offset = 0;
char buf[BUFFER_SIZE];
struct stat finfo;
fd = open(f->name, O_RDONLY);
-
if (fd < 0) {
perror("open()");
return -1;
@@ -129,8 +129,10 @@ static int tail_file(struct file_struct *f, int n_lines)
lseek(fd, offset, SEEK_SET);
- while (read(fd, &buf, BUFFER_SIZE) != 0) {
- rc = write(STDOUT_FILENO, buf, f->st_size - offset);
+ while ((rc = read(fd, &buf, BUFFER_SIZE)) != 0) {
+ dprintf(" f->st_size - offset: %lu\n", f->st_size - offset);
+ dprintf(" rc: %d\n", rc);
+ write(STDOUT_FILENO, buf, (size_t) rc);
}
close(fd);