title: Use poll() to check for file modification
body: <p>There is a file and I would like to check it with <code>poll()</code> that the contents have changed.</p>
  
  <p>On Raspi there is a file called gpio value, if the value changed the <code>poll()</code> was triggered with POLLPRI, I would like to do the same with an ordinary file.</p>
  
  <p>Here is the code I am using to check the GPIO file:</p>
  
  <pre><code>int gpio_fd = gpio_fd_open();
  int timeout = POLL_TIMEOUT;
  struct pollfd fdset;
  int nfds = 1;
  char *buf[MAX_BUF];
  int len;
  int rc;
  fdset.fd = gpio_fd;
  fdset.events =  POLLPRI | POLLERR | POLLHUP | POLLNVAL; // POLLIN | | POLLOUT 
  unsigned int c1, c2, c3;
  do{
      rc = poll(&amp;fdset, 1, timeout);
  </code></pre>
  
  <p>And the gpio_fd_open function:</p>
  
  <pre><code>int gpio_fd_open() {
      printf("opening File: " SYSFS_GPIO_DIR "\n");
  
      int fd, len;
      char buf[MAX_BUF];
  
      len = snprintf(buf, sizeof (buf), SYSFS_GPIO_DIR);
      fd = open(buf, O_RDONLY | O_NONBLOCK);
      if (fd &lt; 0) {
          perror("gpio/fd_open");
      }
      return fd;
  }
  </code></pre>