Linux's inotify framework
While brilliant for network I/O, these multiplexing APIs, though they can in theory be used for monitoring regular file descriptors, will simply report them as always being ready (for reading, writing, or an error condition has arisen), thereby diminishing their usefulness (when used upon regular files).
Perhaps Linux's inotify framework, a means to monitor filesystem events including events on individual files, might be what you are looking for. The inotify framework provides the following system calls to help developers monitor files: inotify_init(2), inotify_add_watch(2) (which can be subsequently read(2)), and then inotify_rm_watch(2). Check out the man page on inotify(7) for more details: http://man7.org/linux/man-pages/man7/inotify.7.html ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access