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, ...
Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.