kqueues for File System Monitoring
Usually when you hear kqueue being discussed on the Internet, it is regarding monitoring the file system. You can use EVFILT_VNODE to watch a file or a directory for changes and then react to those changes. You might want to watch a directory for changes and then pick up any files that have been placed in that directory, leading to “drop-box” functionality for the user. You could also implement an efficient tail -f feature by waiting for a file to have data written to it.
The filter used is EVFILT_VNODE. A vnode, short for virtual node, is a kernel data structure that contains information about a file or folder, with a unique vnode allocated in the kernel for each active file or folder. vnodes are part of VFS, ...
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