title: The read method on the inotify descriptor does not return
body: <p>My program monitors changes on files using <a href="http://linux.die.net/man/7/inotify" rel="nofollow"><code>inotify(7)</code></a></p>
  
  <pre><code>fd = inotify_init();
  inotify_add_watch (fd, "./test.txt", IN_ALL_EVENTS);
  //start forever monitor
  while(true){
         ssize_t len, i = 0;
         char action[81+FILENAME_MAX] = {0};
         char buff[BUFF_SIZE] = {0};
         len = read (fd, buff, BUFF_SIZE);
         while (i &lt; len) {
             //process event
             i += sizeof(struct inotify_event) + pevent-&gt;len;
         }
  }
  </code></pre>
  
  <p>The problem is that the read function only return several times for the firt changes in the monitor file (ACCESS, OPEN, MODIFY events). Unfortunately after that, the read function does not return any more although there a lot of changes in the monitored file.</p>
  
  <p>However, If I reset the inotify descriptor and readd the monitered file agains, ==> the read function always return.</p>
  
  <pre><code>//start forever monitor
  while(true){
         ssize_t len, i = 0;
         char action[81+FILENAME_MAX] = {0};
         char buff[BUFF_SIZE] = {0};
         fd = inotify_init();
         inotify_add_watch (fd, "./test.txt", IN_ALL_EVENTS);
         len = read (fd, buff, BUFF_SIZE);
         while (i &lt; len) {
             //process event
             i += sizeof(struct inotify_event) + pevent-&gt;len;
         }
  }
  </code></pre>
  
  <p>Could you guys help me explain this error. Thanks so much!!!!!!</p>