title: Why is this message not only displayed when a file is written to (using the poll C Linux function)?
body: <p>I was reading about poll in C programming and built an application given on the <a href="https://linux.die.net/man/2/poll" rel="nofollow noreferrer">poll(2) man page</a>.</p>
  
  <p>Here is the example:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include&lt;stdio.h&gt;
  #include &lt;stropts.h&gt;
  #include &lt;poll.h&gt;
  #include &lt;fcntl.h&gt;
  
  int main() {
  
      struct pollfd fds[2];
      int timeout_msecs = -1;
      int ret;
      int i;
  
      /* Open STREAMS device. */
      fds[0].fd = open("/home/jeshwanth/mywork/poll/dev0", O_RDONLY);
      fds[1].fd = open("/home/jeshwanth/mywork/poll/dev1", O_RDONLY);
      fds[0].events = POLLOUT | POLLWRBAND;
      fds[1].events = POLLOUT | POLLWRBAND;
  
      while (1) {
          ret = poll(fds, 2, timeout_msecs);
  
          if (ret &gt; 0) {
              /* An event on one of the fds has occurred. */
              for (i = 0; i &lt; 2; i++) {
                  if (fds[i].revents != 0) {
                      /* Priority data may be written on device number i. */
                      printf(
                              "Priority Data may be written on device number %d POLLWRBAND\n",
                              i);
  
                  }
                  if (fds[i].revents = !0) {
                      /* Data may be written on device number i. */
                      printf("Data may be written on device number %d POLLOUT\n",
                              i);
                  }
                  if (fds[i].revents = !0) {
                      /* A hangup has occurred on device number i. */
                      printf("A hangup has occurred on device number %d\n", i);
  
                  }
              }
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>Note: dev0 and dev1 are normal files. When I run the program, if no event occurred in dev0 and dev1, the message is displayed. But I was expecting when some write into the file happens, only then should it display the message. Am I wrong?</p>