From 60cacd2e41e17aeaf7dcbdfe4057028a5b8b9d1a Mon Sep 17 00:00:00 2001 From: Chuck Silvers Date: Mon, 1 Feb 2021 16:21:14 -0800 Subject: [PATCH] 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 (cherry picked from commit 7787e7eed9d2a43fb6eb66666040f1b495995a2f) (cherry picked from commit 8c59e863e2c03c3b4ab2c403243561a4cc4fcb10) Approved by: so Errata: FreeBSD-EN-22:05.tail --- usr.bin/tail/forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c index 2888bd18816..878cb5a4550 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -367,7 +367,7 @@ follow(file_info_t *files, enum STYLE style, off_t off) continue; ftmp = fileargs_fopen(fa, file->file_name, "r"); if (ftmp == NULL || - fstat(fileno(file->fp), &sb2) == -1) { + fstat(fileno(ftmp), &sb2) == -1) { if (errno != ENOENT) ierr(file->file_name); show(file); -- 2.45.0