Nice writeup. I work on native macOS utilities and have dealt with file monitoring quite a bit. kqueue is reliable but the per-file descriptor requirement can get tricky when you need to watch large directory trees. For anyone looking at this space, FSEvents is the higher-level alternative Apple provides. It watches directory-level changes without needing a file descriptor per file, which scales better for broad moni…
Detecting file changes on macOS with kqueue
11–19 of 19 posts
Re: Detecting file changes on macOS with kqueue
#12Nice writeup. I work on native macOS utilities and have dealt with file monitoring quite a bit. kqueue is reliable but the per-file descriptor requirement can get tricky when you need to watch large directory trees. For anyone looking at this space, FSEvents is the higher-level alternative Apple provides. It watches directory-level changes without needing a file descriptor per file, which scales better for broad moni…
Re: Detecting file changes on macOS with kqueue
#13Path units in systemd present inotify, but their use is somewhat constrained.
The incron utility is more flexible.
Re: Detecting file changes on macOS with kqueue
#14Re: Detecting file changes on macOS with kqueue
#15Nice writeup. I work on native macOS utilities and have dealt with file monitoring quite a bit. kqueue is reliable but the per-file descriptor requirement can get tricky when you need to watch large directory trees. For anyone looking at this space, FSEvents is the higher-level alternative Apple provides. It watches directory-level changes without needing a file descriptor per file, which scales better for broad moni…
Can you treat kqueue as infallible? I've found FSEvents sometimes drops events at high volume (unless I'm misunderstanding how to use it).
Re: Detecting file changes on macOS with kqueue
#16Syntax example: `watchexec -r -e py uv run pytest -xvvs file.py`
Re: Detecting file changes on macOS with kqueue
#17Nice writeup. I work on native macOS utilities and have dealt with file monitoring quite a bit. kqueue is reliable but the per-file descriptor requirement can get tricky when you need to watch large directory trees. For anyone looking at this space, FSEvents is the higher-level alternative Apple provides. It watches directory-level changes without needing a file descriptor per file, which scales better for broad moni…
NSFilePresenter is an even higher level API and the one I typically recommend to people since it’s very easy to use
Re: Detecting file changes on macOS with kqueue
#18Re: Detecting file changes on macOS with kqueue
#19This style/format is really easy to follow along with, great blog writing. Separately I’ve been messing with some filesystem stuff so it’s interesting to me.