Detecting file changes on macOS with kqueue
5 days ago
- #macOS
- #kqueue
- #Go
- Explores detecting file changes on macOS using the kqueue event notification interface.
- Describes the reload tool in Go for recompiling C files and rebuilding static sites on file changes.
- Details the kqueue system, including kevent data structures and filters like EVFILT_VNODE and NOTE_WRITE.
- Covers implementing file watching in C for named files and directories.
- Switches to Go for implementation, with code snippets for setting up kqueue, adding files, and handling events.
- Addresses issues like file descriptor leakage, scaling limitations, and alternatives like FSEvents.
- Highlights practical considerations, such as using O_CLOEXEC to prevent descriptor inheritance by child processes.