mirror of
https://github.com/topjohnwu/ndk-busybox.git
synced 2024-12-14 15:28:38 +00:00
applying fix for:
0000265: tail -f should keep following files even if they were truncated
This commit is contained in:
parent
982d35ffa2
commit
4905434b8a
@ -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)
|
static ssize_t tail_read(int fd, char *buf, size_t count)
|
||||||
{
|
{
|
||||||
ssize_t r;
|
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) {
|
if ((r = safe_read(fd, buf, count)) < 0) {
|
||||||
bb_perror_msg("read");
|
bb_perror_msg("read");
|
||||||
status = EXIT_FAILURE;
|
status = EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user