aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2005-07-20 19:46:32 +0000
committerPaul Fox <pgf@brightstareng.com>2005-07-20 19:46:32 +0000
commit4905434b8aead249d6bdd134d2fbd8c06dfcc059 (patch)
tree663e7067e0fdd7c81b60260d60176317b3b3f890 /coreutils/tail.c
parent982d35ffa2e4ee673bb74f1984d585108f4bf4c2 (diff)
downloadbusybox-4905434b8aead249d6bdd134d2fbd8c06dfcc059.tar.gz
applying fix for:
0000265: tail -f should keep following files even if they were truncated
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index e3f89d2ee..d49539916 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -79,7 +79,19 @@ static void tail_xbb_full_write(const char *buf, size_t len)
static ssize_t tail_read(int fd, char *buf, size_t count)
{
ssize_t r;
+ off_t current,end;
+ struct stat sbuf;
+ int ret;
+ end = current = lseek (fd, 0, SEEK_CUR);
+ if (!fstat(fd, &sbuf)){
+ end = sbuf.st_size;
+ }
+ if ( end < current) {
+ lseek(fd, 0, SEEK_SET);
+ } else {
+ lseek(fd, current, SEEK_SET);
+ }
if ((r = safe_read(fd, buf, count)) < 0) {
bb_perror_msg("read");
status = EXIT_FAILURE;