diff options
author | pgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-07-20 19:46:32 +0000 |
---|---|---|
committer | pgf <pgf@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-07-20 19:46:32 +0000 |
commit | f58ceacd59c45673be0bb3675bbab4e09164bc61 (patch) | |
tree | 663e7067e0fdd7c81b60260d60176317b3b3f890 | |
parent | 2455279a67adfdfe4a809274b0852fe15238bb44 (diff) | |
download | busybox-w32-f58ceacd59c45673be0bb3675bbab4e09164bc61.tar.gz busybox-w32-f58ceacd59c45673be0bb3675bbab4e09164bc61.tar.bz2 busybox-w32-f58ceacd59c45673be0bb3675bbab4e09164bc61.zip |
applying fix for:
0000265: tail -f should keep following files even if they
were truncated
git-svn-id: svn://busybox.net/trunk/busybox@10884 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | coreutils/tail.c | 12 |
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) | |||
79 | static ssize_t tail_read(int fd, char *buf, size_t count) | 79 | static 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; |