Implementing tail -f
Implementing tail -f is surprisingly difficult and complicated…
# Quora
The basic problem is to use the available system calls on the host operating system to detect when a file has new content in it.
For efficiency, both the GNU version and the NetBSD version make use of kernel support for notification of file modification if possible; GNU uses inotify and NetBSD uses kqueue. This involves registering interest in the specified file(s) with the kernel and then making a blocking call to the kernel which will return when something interesting (i.e., an append) has occured.
# GNU & bsd sources
# inotify
# inotify.cr
# c example
# man
Written on August 20, 2018, Last update on July 27, 2020
software
architecture
kernel
filesystem
concurrency