title: inotify don't treat vim editting as a modification event
body: <p>my example code below watches a file for being modified. let's say the file being wathched is foo.txt, and the binary name came out from the sample code is inotify. I did two test for the sample code.</p>
  
  <p>test1:<br>
  1) ./inotify foo.txt<br>
  2)  echo "hello" > foo.txt<br>
  then everything works fine,and "<strong>file modified</strong>" has been printed out.</p>
  
  <p>test2:<br>
  1) ./infity foo.txt<br>
  2) vim foo.txt<br>
  3) edit somehow and save,but don't quit vim<br>
  the printed out line is  <strong>unknown Mask 0x00008000</strong>, checked out the inotify header file found this event mask mean <strong>IN_CLOSE_WRITE</strong>.</p>
  
  <p>from my point of view, "edit and save" just menas modify. but obvisously the inotify code has a different interpration for it. it's strange for me, can anyone help to explain the things behind?</p>
  
  <pre><code>#include &lt;sys/inotify.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  int main(int argc, char **argv)
  {
    int fdnotify = -1; 
  
    if (argc !=2) {
      fprintf(stderr, "usage: ./inotify dir_name\n");
      exit(1);
    }
  
    printf("argc is %d\n", argc);
  
    fdnotify = inotify_init();
    if (fdnotify &lt; 0) {
      fprintf(stderr, "inotity_init failed: %s\n", strerror(errno));
    }
  
    int wd = inotify_add_watch(fdnotify, argv[1], IN_MODIFY);
    if (wd &lt; 0) {
      fprintf(stderr, "inotify_add_watch failed: %s\n", strerror(errno));
    }
  
    while(1) {
      char buffer[4096];
      struct inotify_event *event = NULL;
  
      int len = read(fdnotify, buffer, sizeof(buffer));
  
      if (len &lt; 0) {
        fprintf(stderr, "read error %s\n", strerror(errno));
      }   
  
      event = (struct inotify_event *) buffer;
  
      while(event != NULL) {
        if ((event-&gt;mask &amp; IN_MODIFY)  ) { 
          printf("File modified %s\n", event-&gt;name);
        } else {
   printf("unknown Mask 0x%.8x\n", event-&gt;mask);
        }
        len -= sizeof(*event) + event-&gt;len;
  
        if (len &gt; 0)
          event = ((void *) event) + sizeof(event) + event-&gt;len;
        else
          event = NULL;
      }
    }
  }
  </code></pre>