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 | |
parent | 0c0c6cc425194293d362867f048cc07113f8947c (diff) | |
parent | 0a02ab4945c5cf65e305319e2c1ea49d4dbe3a97 (diff) |
Merge branch 'master' into followname
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | changelog | 9 | ||||
-rw-r--r-- | inotail.c | 6 |
3 files changed, 14 insertions, 3 deletions
@@ -4,7 +4,7 @@ # # Licensed under the terms of the GNU General Public License; version 2 or later. -VERSION = 0.6-pre0 +VERSION = 0.6 # Paths prefix = /usr/local @@ -1,3 +1,12 @@ +inotail 0.6 + + * Correctly handle tailing from pipes + * Do not try to seek on pipes when following (thanks Alexander Sulfrian) + * Handle file truncation in follow mode + * Various small fixes + + -- Tobias Klauser <tklauser@distanz.ch> 2008-08-31 21:15 + inotail 0.5 * Output verbose file headers correctly when used in a pipe @@ -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; } |