From ec2c7cba0e2a9f3f4c15119525fa16d1a359a6b2 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 31 Aug 2008 21:34:16 +0200 Subject: Check for file being a pipe before seeking Otherwise inotail -f on a named pipe (fifo) would not work. Thanks Alexander Sulfrian. --- inotail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inotail.c b/inotail.c index d708f1f..62920ba 100644 --- a/inotail.c +++ b/inotail.c @@ -591,7 +591,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; } -- cgit v1.2.3-54-g00ecf From a1b82a30dc7133b4fbcaa132ce5ef85c4771aafc Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 31 Aug 2008 21:45:18 +0200 Subject: Prepare inotail 0.6 Presumably this version will not yet include the follow by name feature and the fixes for the file rotation issue (Debian bug #460527). Will have to find some time first to have a closer look at these two. --- Makefile | 2 +- changelog | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 34a6041..5e96f38 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/changelog b/changelog index f25cc5e..83696c2 100644 --- a/changelog +++ b/changelog @@ -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 2008-08-31 21:15 + inotail 0.5 * Output verbose file headers correctly when used in a pipe -- cgit v1.2.3-54-g00ecf From 0a02ab4945c5cf65e305319e2c1ea49d4dbe3a97 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 14 Nov 2008 15:12:39 +0100 Subject: More comments and clearify a return statement. --- inotail.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3-54-g00ecf