HP-UX Reference (11i v2 07/12) - 7 Device (Special) Files, 9 General Information, Index (vol 10)

p
poll(7) poll(7)
After the last non-blocking write succeeds, the following should be used to deregister for
POLLOUT, but
continue to be registered for input notifications. Note that
POLLREMOVE must be used in order to remove
the
POLLOUT registration.
struct pollfd regpfd[2];
int err;
regpfd[0].fd = sd;
regpfd[0].events = POLLREMOVE;
regpfd[1].fd = sd;
regpfd[1].events = POLLIN;
err = write(evpfd, regpfd, sizeof(regpfd));
The following uses ioctl(DP_ISPOLLED)
to demonstrate how to accomplish the same thing in the
more general case, for example, when an application library might not know how the file descriptor is nor-
mally registered.
struct pollfd regpfd[2];
int err;
regpfd[0].fd = sd;
regpfd[0].events = POLLREMOVE;
regpfd[1].fd = sd;
err = ioctl(evpfd, DP_ISPOLLED, &regpfd[1]);
regpfd[1].events &= ˜POLLOUT; /* clear POLLOUT */
err = write(evpfd, regpfd, sizeof(regpfd));
WARNINGS
/dev/poll usually performs better than select() and poll() especially when the application has
registered a very large number of file descriptors. However, in cases where specified conditions are likely
to occur simultaneously on a large number of registered file descriptors, performance levels will be dimin-
ished.
If open() returns -1 and errno is set to [ENXIO], this indicates that some of the necessary system
patches have not been installed, and the system administrator must install the File System, Transport, and
STREAMS patches that support /dev/poll (event ports).
The write() system call does not return any error indication if one or more of the file descriptors in the
pollfd structure could not be registered or deregistered.
If POLLREMOVE is ORed with other poll conditions in a pollfd structure passed to write()
,
POLLREMOVE is ignored. The other poll conditions will be ORed with any existing poll conditions for the
registered file descriptor.
The ioctl(DP_POLL) system call returns only the first dp_nfds active file descriptors. There is no indi-
cation if there are additional active file descriptors.
The
ioctl(DP_ISPOLLED)
system call also returns its result in the revents member of the pollfd
structure, in order to be compatible with the implementation of the
/dev/poll driver by some other ven-
dors.
The
ioctl(DP_ISPOLLED) system call does not return any error indication if the file descriptor in the
pollfd structure is not open.
When an event port is closed, the close() system call might take a noticeable amount of time to com-
plete if a very large number of file descriptors is still registered.
AUTHOR
The event port driver was developed independently by HP.
FILES
/dev/poll driver device file
/sbin/init.d/devpoll start-up script that creates /dev/poll
/etc/rc.config.d/devpoll
configuration parameters for start-up script
110 Hewlett-Packard Company 4 HP-UX 11i Version 2: December 2007 Update