I'm coding a macOS launch daemon (in C++) and I need to know when a certain file on local disk was changed. Does the OS provide such notifications?
PS. I was trying to avoid polling that file for a change every N seconds in a loop.
While it is possible to achieve some success in monitoring file changes with kqueue, as proposed by Sam in comments, I would recommend to use other approach.
Try to use the FSEvents API. It is much more convenient than old-style kqueue stuff and could be easy integrated into c++ code. It is also from the CoreServices Framework, so it could be safely used in daemons on macOS (search by "Daemon-Safe Frameworks")
The most important part of it is to subscribe to the events of interest, to have a separate event loop, and to release all these things correctly once the job is done.
From the first look it seems you can make use of kFSEventStreamEventFlagItemModified flag.
In both ways you will need to clarify for yourself, what kind of "file was changed" definitions are interesting for you and adjust the event flags accordingly.
There is no NOTE_CLOSE_WRITE on macOS, by the way, however there are some other useful flags for your case.