From 421da3ce09ed24185a14d45606256a5602e0b848 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 13 Sep 2006 21:40:24 +0200 Subject: Further cleanup --- inotail.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'inotail.c') diff --git a/inotail.c b/inotail.c index 1603dd3..e011489 100644 --- a/inotail.c +++ b/inotail.c @@ -74,7 +74,6 @@ static void write_header(const char *filename) static off_t lines_to_offset(struct file_struct *f, unsigned int n_lines) { - int i; char buf[BUFFER_SIZE]; off_t offset = f->st_size; @@ -84,7 +83,7 @@ static off_t lines_to_offset(struct file_struct *f, unsigned int n_lines) n_lines += 1; while (offset > 0 && n_lines > 0) { - int rc; + int i, rc; int block_size = BUFFER_SIZE; /* Size of the current block we're reading */ if (offset < BUFFER_SIZE) @@ -173,9 +172,8 @@ static int tail_file(struct file_struct *f, int n_lines, char mode) lseek(f->fd, offset, SEEK_SET); - while ((rc = read(f->fd, &buf, BUFFER_SIZE)) > 0) { + while ((rc = read(f->fd, &buf, BUFFER_SIZE)) > 0) write(STDOUT_FILENO, buf, (size_t) rc); - } if (close(f->fd) < 0) fprintf(stderr, "Error: Could not close file '%s' (%s)\n", f->name, strerror(errno)); @@ -292,6 +290,8 @@ static int watch_files(struct file_struct *f, int n_files) } } + close(ifd); + return -1; } -- cgit v1.2.3-54-g00ecf ='packet-rx-pump-back'>packet-rx-pump-back net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode: