Live data from Hacker News

Detecting file changes on macOS with kqueue

vegardstikbakke.com

11–19 of 19 posts

Re: Detecting file changes on macOS with kqueue

#11

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…

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

#12

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…

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

#14
This looks interesting and I might give it a try. I did look at FSEvents in the past but due to my needs in macOS app, I took a very niche (and not so fast) approach of running find | ls -lT | shasum spawned in a separate process to reliably tell if a folder has changed.

Re: Detecting file changes on macOS with kqueue

#15
post #11

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…

Can you treat kqueue as infallible? I've found FSEvents sometimes drops events at high volume (unless I'm misunderstanding how to use it).

That's the exciting thing about macOS development, right? There's always some funny riddles because Apple doesn't care to document stuff for 3rd parties (or at all).

Re: Detecting file changes on macOS with kqueue

#17

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…

NSFilePresenter is an even higher level API and the one I typically recommend to people since it’s very easy to use

[flagged]
Post reply on HN