poll() - synchronous I/O multiplexing
#include <poll.h>
int poll(struct pollfd *fds, int nfds, int timeout)
The poll(3) function provides a mechanism for reporting I/O conditions across a set of file descriptors.
The arguments are as follows:
struct pollfd {
int fd;
short events;
short revents;
};
The fd member is an open file descriptor that refers to the
file /proc/procID/ctl, where procID is
the process ID of a process running on the system. (The poll
function is not supported for use with other files.) The
events and revents members are bitmasks of conditions
to monitor and conditions found, respectively.The calling process sets the events bitmask and poll() sets the revents bitmask. Each call to poll() resets the revents bitmask for accuracy. The condition flags in the bitmasks are defined as:
If timeout is neither zero nor -1, it specifies a maximum interval to wait for any file descriptor to become ready, in milliseconds. If timeout is -1, the poll blocks indefinitely. If timeout is zero, the poll() returns without blocking.
The poll() function returns the number of descriptors that are ready for I/O, or -1 if an error occurred. If the time limit expires, poll() returns 0. If poll() returns with an error, including one due to an interrupted call, the fds array will be unmodified.
On Interix, poll() is supported only for use with ctl files (located in /proc/procID). No other file types are allowed.
accept(2)
connect(2)
read(2)
recv(2)
select(2)
send(2)