summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2006-09-13 21:40:24 +0200
committerTobias Klauser <tklauser@xenon.tklauser.home>2006-09-13 21:40:24 +0200
commit421da3ce09ed24185a14d45606256a5602e0b848 (patch)
treedb546574b3635e4702c593f8c5eaa9be0b4a0f68
parent4f3beb21195c0419a9f17cd370bc84a0ab46f8db (diff)
Further cleanup
-rw-r--r--inotail.c8
1 files changed, 4 insertions, 4 deletions
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;
}