【发布时间】:2022-03-08 15:27:23
【问题描述】:
我的程序使用inotify 来监控文件的更改。 我的代码如下:
fd = inotify_init();
wd = inotify_add_watch(fd, "./test.txt", IN_ALL_EVENTS);
len = read(fd, buff, BUFF_SIZE);
while (i < len) {
struct inotify_event *pevent = (struct inotify_event *) &buff[i];
//process events
i += sizeof(struct inotify_event) + pevent->len;
}
但是,在我收到了几个事件以在受监控文件中进行第一次更改(事件IN_OPEN、IN_MODIFY、IN_ACESS 等)之后,受监控文件中的后续更改确实会生成任何其他事件 ==>我的程序挂在读取函数(读取被阻止)
你们能帮我解释一下这个错误吗?
【问题讨论】:
标签: c++ c inotify file-monitoring