2

The man page of the poll function says:

   ...       
   int poll(struct pollfd *fds, nfds_t nfds, int timeout);
   ...

   struct pollfd {
               int   fd;         /* file descriptor */
               short events;     /* requested events */
               short revents;    /* returned events */
           };
   ...
   The field fd contains a file descriptor for an open file.  If this
   field is negative, then the corresponding events field is ignored and
   the revents field returns zero.  (This provides an easy way of
   ignoring a file descriptor for a single poll() call: simply negate
   the fd field.  Note, however, that this technique can't be used to
   ignore file descriptor 0.)

So if I define the pollfd structure as follows:

   struct pollfd pollevent;
   pollevent.fd=-1;
   pollevent.event=POLLIN;

Does it mean that for a file opened with fd=1, all the POLLIN events will be ignored?

1 Answers1

0

No. Only the struct pollfd with the negative file descriptor will be ignored.