c - inotify_event 返回 wd -1

标签 c linux inotify

我正在使用 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/

相关文章:

c - gcc "relocation R_X86_64_PC32 against symbol ` ff_M24A'"在 linux 上静态链接 ffmpeg 时出错

c++ - QSocketNotifier - 如何使用它来监视文件? - linux

linux - 如何在不使用 inotifywait 的情况下监视目录中的文件更改?

monitoring - linux inotify - 确定触发事件的用户

c - C 中指针的问题。相同的指针用于不同的事物

java - 如何使用 cli 更新配置文件的 ~/.aws/credentials 文件中的 aws key ?

regex - 使用 sed 缩进行范围?

c - DirectFB教程无效参数

c - poll/select 和 writefds 的最佳实践

c - 如何使用 MINGW 运行 C 代码/文件?