I/O Polling

The function poll(2) represents another way to perform efficient I/O scheduling. It was originally developed by AT&T to be used for STREAMS file descriptors. However, poll(2) now accepts all file descriptors. The function synopsis for poll(2) is as follows:

/*
 * UnixWare 7, SGI IRIX 6.5 :
 */
#include <stropts.h>
#include <poll.h>

/*
 * HP-UX 11.x, Solaris 8 :
 */
#include <poll.h>

/*
 * IBM AIX 4.3 :
 */
#include <sys/poll.h>
#include <sys/select.h>
#include <sys/types.h>

/*
 * FreeBSD :
 */
#include <sys/types.h>
#include <poll.h>

int poll(struct pollfd *fds, unsigned int nfds, int timeout);
struct pollfd {
    int    fd;        /* file descriptor */
    short  events;    /* events to look for */
    short  revents;   /* returned events */
} ;

As you can see, the ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.