inotify / stat:可能的竞争条件

时间:2018-05-15 11:27:05

标签: linux stat inotify

以C用户root运行的Linux中的两个进程基本上执行以下操作:(初始化未显示)

答:

fd=open("/watch/item", O_CREAT, 0);
close(fd);

B:

inotify_add_watch(inotify_fd, "/watch", IN_CREATE);
stat("/watch/item");
// then poll and process the inotify event

在极少数情况下,stat()会返回-1,但稍后不会再捕获更多的inotify事件。

假设是否存在竞争条件,当已经生成inotify事件(inotify_add_watch()尚未完成)但之后stat()仍然返回-1?

0 个答案:

没有答案