diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2008-12-15 23:55:57 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2008-12-15 23:55:57 +0100 |
commit | 03a70c5519c75abd4e09509434ba11d39aad1a2f (patch) | |
tree | e8021b45a1266119e41dfe1dac021d61f23996c3 /inotail.c | |
parent | 0c0c6cc425194293d362867f048cc07113f8947c (diff) | |
parent | 0a02ab4945c5cf65e305319e2c1ea49d4dbe3a97 (diff) |
Merge branch 'master' into followname
Diffstat (limited to 'inotail.c')
-rw-r--r-- | inotail.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; } |