我正在使用 inotify_init()
初始化 INOTIFY
,并且调用 read
时没有屏蔽标志。当我想使用监视描述符 wd
时,我可以看到它返回值 -1。阅读手册页我可以看到仅当偶数队列溢出时才设置此值,但仅当对读取的调用设置了 mas 位 IN_Q_OVERFLOW 时才设置,所以这不是我的情况。
将 wd 设置为 -1 的原因可能是什么?最重要的是,我没有通过读取返回 -1,所以这意味着在此过程中没有错误。
最佳答案
那你看错手册了,inotify_init(2)明确地说:
On success, these system calls return a new file descriptor. On error, -1 is returned, and errno is set to indicate the error.
所以看看 errono,看看你做错了什么。
关于c - inotify_event 返回 wd -1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15617764/