inotify_add_watch return 是否按升序观看描述符?

Does inotify_add_watch return watch descriptors in ascending order?

inotify_add_watch return 一个整数。

我想将我正在观看的路径的字符串存储在一个数组中,并希望通过 inotify_add_watch 的 return 值对它们进行索引。

我做了一个小规模测试(有 10 个文件),它似乎 return 它们按升序排列(1、2、3、4...)。

这个有保障吗?

the documentation 中没有任何内容可以保证这一点。

其实这个案例:

If the filesystem object was already being watched (perhaps via a different link to the same object), then the descriptor for the existing watch is returned.

似乎把答案直接放在"no"。

您会依赖 open 以升序返回文件描述符吗?这是同样的情况。