Linux: 文档 :相关接口文档手册还是需要仔细阅读

接口文档的阅读,一定要仔细。最近遇到一个问题,明明文档里有说,read函数读取到的是一个或者多个events,但是代码里依然按照一个来处理。就会导致漏event的可能。漏了event,后续的逻辑就会受影响。
Each successful read(2) returns a buffer containing one or more of the following

structures:
           struct inotify_event {
               int      wd;       /* Watch descriptor */
               uint32_t mask;     /* Mask describing event */
               uint32_t cookie;   /* Unique cookie associating related
                                     events (for rename(2)) */
               uint32_t len;      /* Size of name field */
               char     name[];   /* Optional null-terminated name */
           };

wd identifies the watch for which this event occurs. It is one of the watch descriptors returned by a previous call to inotify_add_watch(2).

这种读文档不仔细的例子,之前还碰到过一两次。有可能大家只是用,从来不读帮助手册,这是不可取的。

你可能感兴趣的:(c/c++,笔记,linux,文档,接口)