Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

19. Monitoring File Events > Reading inotify Events

Reading inotify Events

Having registered items in the watch list, an application can determine which events have occurred by using read() to read events from the inotify file descriptor. If no events have occurred so far, then read() blocks until an event occurs (unless the O_NONBLOCK status flag has been set for the file descriptor, in which case the read() fails immediately with the error EAGAIN if no events are available).

After events have occurred, each read() returns a buffer (see Figure 19-2) containing one or more structures of the following type:

struct inotify_event {
    int      wd;          /* Watch descriptor on which event occurred */
    uint32_t mask;        /* Bits describing event that occurred */
    uint32_t cookie;      /* Cookie for related events (for rename()) */
    uint32_t len;         /* Size of 'name' field */
    char     name[];      /* Optional null-terminated filename */
};

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint