Skip to content

tail: watch the followed file itself under inotify - #16693

Open
lmilz wants to merge 1 commit into
uutils:mainfrom
lmilz:tail-watch-followed-file
Open

lmilz wants to merge 1 commit into
uutils:mainfrom
lmilz:tail-watch-followed-file

Conversation

@lmilz

@lmilz lmilz commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

When following a regular file on Linux, tail previously only placed an inotify watch on the parent directory (watching the file itself only for symlinks), whereas GNU tail also watches the file and drops that watch once the file is rotated. While the output of tail -F was the same, the GNU test tests/tail/inotify-rotate-resources.sh inspects the active inotify watches and failed because the file watch was missing.

Under inotify (leaving the polling backend unchanged), tail now also watches the followed file across rotations, and a new test verifies the watched inodes via /proc/<pid>/fdinfo.

Closes #16650

With -F, tail only put an inotify watch on the directory of a followed file,
while GNU also watches the file and drops that watch once the file is rotated
away. The output was the same, but the GNU test
tests/tail/inotify-rotate-resources.sh checks for these watches.

Watch the file as well, and watch the new file again when it is reopened after
a rotation. notify drops the old watch by itself once the name is renamed or
removed. As both watches now report the name going away, report a missing
file only once. The old watch is dropped before the old file is closed:
closing a replaced file can free its inode, and the watch would then report
the name as deleted. The polling backend keeps watching only the directory,
since it reorders events when it watches both.

Fixes uutils#16650

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tail: -F does not watch the followed file itself, only its directory

1 participant