During implementation of utility (which purpose does not matter in context of this post) we needed to implement tail -f like behavior (i.e continuously read file updates). Traditional I/O multiplexing API (either POSIX select(2)/poll(2) or Linux specific epoll(2) does not work on regular files and return that file is always readable or EPERM error, depending on interface used.
In order to check for file changes we need another interface. In Linux systems we can use inotify API mechanism which we can use to check for file changes. After initializing inotify instance with inotify_init(2), we can add file to watch using inotify_add_watch(2), which returns watch descriptor. Now we can use this descriptor in I/O multiplexing API (select/poll/epoll), which will notify once descriptor is readable (i.e. there are I/O events for specified watched descriptor with associated file(s)).
Bellow is sample code which implements rudimentary tail -f behavior: only one file can be specified, code prints only changes made after executing command, code error checking is also lacking (no interruption by signal is checked, etc).