tail: fix "tail -F" file rotation detection

When checking if the newly opened file is the same as the old one,
we need to fstat() the new file descriptor, not the old one again.

Reviewed by:	glebius
Sponsored by:	Netflix
This commit is contained in:
Chuck Silvers 2021-02-01 16:21:14 -08:00
parent 1912d2b15e
commit 7787e7eed9

View File

@ -367,7 +367,7 @@ follow(file_info_t *files, enum STYLE style, off_t off)
continue; continue;
ftmp = fileargs_fopen(fa, file->file_name, "r"); ftmp = fileargs_fopen(fa, file->file_name, "r");
if (ftmp == NULL || if (ftmp == NULL ||
fstat(fileno(file->fp), &sb2) == -1) { fstat(fileno(ftmp), &sb2) == -1) {
if (errno != ENOENT) if (errno != ENOENT)
ierr(file->file_name); ierr(file->file_name);
show(file); show(file);