gpt4 book ai didi

linux - MACOSX (BSD) 等效于 fcntl() 函数的 F_NOTIFY 标志

转载 作者:可可西里 更新时间:2023-11-01 11:50:43 24 4
gpt4 key购买 nike

有人知道基于 BSD 的系统中 fcntl 函数的 F_NOTIFY 标志的等效项吗?此标志允许您接收有关文件事件的通知(例如打开文件、关闭文件、写入文件的字节数、从文件读取的字节数)。该标志在 Linux 中存在,但在 MACOSX(基于 BSD 的系统)中不存在。

引自 linux man:

File and directory change notification (dnotify)

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

F_NOTIFY (long) (Linux 2.4 onwards) Provide notification when the directory referred to by fd or any of the files that it contains is changed.

实际上,任何允许我接收文件事件的 API 对我来说都足够了。

有人知道是否存在 F_NOTIFY 的替代品吗?此时我只有一个想法:使用kqueue()、kevent()函数。

最佳答案

没有确切的等价物; kqueue()/kevent()带有 EVFILT_VNODE 事件过滤器的是 OS X 上的替代品。

请注意,即使在 Linux 中,F_NOTIFY 也已被 inotify 取代.

关于linux - MACOSX (BSD) 等效于 fcntl() 函数的 F_NOTIFY 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5167004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com