Penguin
Annotated edit history of poll(2) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 poll - wait for some event on a file descriptor
1 perry 3
4 !!SYNOPSIS
2 PerryLorier 5 __#include <sys/poll.h>__
1 perry 6
2 PerryLorier 7 __int poll(struct pollfd *__''ufds''__, unsigned int__ ''nfds''__, int__ ''timeout''__);__
1 perry 8
9 !!DESCRIPTION
2 PerryLorier 10 poll(2) is a variation on the theme of __select__. It specifies an array of ''nfds'' structures of type
1 perry 11
2 PerryLorier 12 struct pollfd {
13 int fd; /* file descriptor */
14 short events; /* requested events */
15 short revents; /* returned events */
16 };
1 perry 17
2 PerryLorier 18 and a ''timeout'' in milliseconds. A negative value means infinite timeout. The field ''fd'' contains a file descriptor for an open file. The field ''events'' is an input parameter, a bitmask specifying the events the application is interested in. The field ''revents'' is an output parameter, filled by the kernel with the events that actually occurred, either of the type requested, or of one of the types __POLLERR__ or __POLLHUP__ or __POLLNVAL__. (These three bits are meaningless in the ''events'' field, and will be set in the ''revents'' field whenever the corresponding condition is true.) If none of the events requested (and no error) has occurred for any of the file descriptors, the kernel waits for ''timeout'' milliseconds for one of these events to occur. The following possible bits in these masks are defined in '<sys/poll.h>'
1 perry 19
2 PerryLorier 20 #define POLLIN 0x0001 /* There is data to read */
21 #define POLLPRI 0x0002 /* There is urgent data to read */
22 #define POLLOUT 0x0004 /* Writing now will not block */
23 #define POLLERR 0x0008 /* Error condition */
24 #define POLLHUP 0x0010 /* Hung up */
25 #define POLLNVAL 0x0020 /* Invalid request: fd not open */
1 perry 26
2 PerryLorier 27 In POLLRDNORM__, __POLLRDBAND__, __POLLWRNORM__, __POLLWRBAND__ and __POLLMSG__ are defined.
1 perry 28
29 !!RETURN VALUE
2 PerryLorier 30 On success, a positive number is returned, where the number returned is the number of structures which have non-zero ''revents'' fields (in other words, those descriptors
31 with events or errors reported). A value of 0 indicates that the call timed out and no file descriptors have been selected. On error, -1 is returned, and ''errno'' is set
32 appropriately.
1 perry 33
34 !!ERRORS
2 PerryLorier 35 ;[EBADF]: An invalid file descriptor was given in one of the sets.
36 ;[ENOMEM]: There was no space to allocate file descriptor tables.
37 ;[EFAULT]: The array given as argument was not contained in the calling program's address space.
38 ;[EINTR]: A signal occurred before any requested event.
1 perry 39
40 !!CONFORMING TO
2 PerryLorier 41 XPG4-UNIX.
1 perry 42
43 !!AVAILABILITY
2 PerryLorier 44 The poll() systemcall was introduced in Linux 2.1.23. The poll() library call was introduced in libc 5.4.28 (and provides emulation using select if your kernel does not have a poll syscall).
1 perry 45
46 !!SEE ALSO
47 select(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 10 times)