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-w32-4905434b8aead249d6bdd134d2fbd8c06dfcc059.tar.gz
busybox-w32-4905434b8aead249d6bdd134d2fbd8c06dfcc059.tar.bz2
busybox-w32-4905434b8aead249d6bdd134d2fbd8c06dfcc059.zip
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)
79static ssize_t tail_read(int fd, char *buf, size_t count) 79static ssize_t tail_read(int fd, char *buf, size_t count)
80{ 80{
81 ssize_t r; 81 ssize_t r;
82 off_t current,end;
83 struct stat sbuf;
84 int ret;
82 85
86 end = current = lseek (fd, 0, SEEK_CUR);
87 if (!fstat(fd, &sbuf)){
88 end = sbuf.st_size;
89 }
90 if ( end < current) {
91 lseek(fd, 0, SEEK_SET);
92 } else {
93 lseek(fd, current, SEEK_SET);
94 }
83 if ((r = safe_read(fd, buf, count)) < 0) { 95 if ((r = safe_read(fd, buf, count)) < 0) {
84 bb_perror_msg("read"); 96 bb_perror_msg("read");
85 status = EXIT_FAILURE; 97 status = EXIT_FAILURE;