MACOSX equivalent (BSD) for the F_NOTIFY flag for the fcntl () function

Does anyone know the equivalent of the F_NOTIFY flag for the fcntl function in a BSD-based system? This flag allows you to receive notifications about file events (for example, the file is open, the file is closed, bytes are written to the file, bytes are read from the file). This flag exists on Linux, but does not exist on MACOSX (BSD-based system).

Quote from linux man:

File and directory change notification (Dnotify)

int fcntl (int fd, int cmd, ... / * arg * /);

F_NOTIFY (long) (Starting with Linux 2.4) Provide a notification when a directory called fd or any of the files that it contains changes.

Actually for me there will be enough API which allows me to receive files.

Does anyone know if there is any replacement for F_NOTIFY? At this time, I have only one idea: using the kqueue (), kevent () functions.

+3
source share
1 answer

There is no exact equivalent; The / s filter event is a replacement for OS X. kqueue()kevent()EVFILT_VNODE

Note that even on Linux, F_NOTIFY has been superseded by inotify .

+5
source

Source: https://habr.com/ru/post/1795723/


All Articles