Repository navigation
Conversation
| watcher: Box<dyn Watcher>, | ||
| receiver: Receiver<Result<notify::Event, notify::Error>>, | ||
| /// Whether `watcher` is a `notify::PollWatcher`. | ||
| #[cfg_attr(not(target_os = "linux"), allow(dead_code))] |
There was a problem hiding this comment.
please avoid the allow(dead_code), #[cfg(target_os = "linux")] on the field should do it
There was a problem hiding this comment.
Done, thanks. This needed a few more changes to keep it compiling on FreeBSD and macOS: WatcherRx::new is removed, and Oberserver::start now builds the structure directly.
|
Binary size comparison: |
|
GNU testsuite comparison: |
ed24981 to
5b650d3
Compare
5b650d3 to
19b2902
Compare
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. A file that cannot be watched, such as an unreadable one, is still followed through its directory. Part of uutils#16650
19b2902 to
02c7ed7
Compare
|
With this change, the inotify watches on the followed file are now added and removed across rotations as expected (verified with However, How would you prefer to proceed: adjusting the GNU test to use |
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.
Under inotify (leaving the polling backend unchanged), tail now also watches the followed file across rotations (ignoring errors when adding the file watch, e.g. on unreadable files, since the directory watch still covers them). New tests verify the watched inodes via
/proc/<pid>/fdinfoand thattail -Fkeeps running on unreadable files. The GNU CI run also reportstests/tail/follow-nameandtests/tail/pid-pipeas newly passing.Note:
tests/tail/inotify-rotate-resources.shstill fails: notify runs its inotify syscalls in a background thread, and the test runs strace without-f, so it only traces the main thread. See the comment below.Part of #16650