1 .\" $NetBSD: poll.2,v 1.3 1996/09/07 21:53:08 mycroft Exp $
2 .\" $FreeBSD: src/lib/libc/sys/poll.2,v 1.4.2.3 2001/12/14 18:34:01 ru Exp $
4 .\" Copyright (c) 1996 Charles M. Hannum. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by Charles M. Hannum.
17 .\" 4. The name of the author may not be used to endorse or promote products
18 .\" derived from this software without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .Nd synchronous I/O multiplexing
45 .Fa "struct pollfd *fds"
51 .Fa "struct pollfd *fds"
53 .Fa "const struct timespec *timeout"
54 .Fa "const sigset_t *newsigmask"
60 examine a set of file descriptors to see if some of them are ready for
64 argument is a pointer to an array of pollfd structures as defined in
69 argument determines the size of the
74 int fd; /* file descriptor */
75 short events; /* events to look for */
76 short revents; /* events returned */
83 .Bl -tag -offset indent -width ".Fa revents"
85 File descriptor to poll.
86 If fd is equal to -1 then
88 is cleared (set to zero), and that pollfd is not checked.
93 Events which may occur.
101 have the following bits:
102 .Bl -tag -offset indent -width ".Dv POLLRDNORM"
104 Data other than high priority data may be read without blocking.
106 Normal data may be read without blocking.
108 Data with a non-zero priority may be read without blocking.
110 High priority data may be read without blocking.
113 Normal data may be written without blocking.
115 Data with a non-zero priority may be written without blocking.
117 An exceptional condition has occurred on the device or socket.
118 This flag is always checked, even if not present in the
122 The device or socket has been disconnected.
123 This flag is always checked, even if not present in the
130 should never be present in the
132 bitmask at the same time.
134 The file descriptor is not open.
135 This flag is always checked, even if not present in the
144 it specifies a maximum interval to
145 wait for any file descriptor to become ready, in milliseconds.
150 the poll blocks indefinitely.
155 will return without blocking.
159 system call can be used to safely wait until either a set of file
160 descriptors becomes ready, or until a signal is caught.
166 .Vt "const struct timespec"
171 A null pointer may be passed to indicate that
173 should wait indefinitely.
176 specifies a signal mask which is set while waiting for input.
179 returns, the original signal mask is restored.
182 returns the number of descriptors that are ready for I/O, or -1 if an
184 If the time limit expires,
189 returns with an error,
190 including one due to an interrupted call,
193 array will be unmodified.
195 This implementation differs from the historical one in that a given
196 file descriptor may not cause
198 to return with an error.
199 In cases where this would have happened in the historical implementation
200 (e.g.\& trying to poll a
202 descriptor), this implementation instead copies the
207 Attempting to perform I/O on this descriptor will then return an error.
208 This behaviour is believed to be more useful.
212 implementation uses a precise timeout which is intended to mimic the
213 behaviour of this syscall in Linux.
221 points outside the process's allocated address space.
223 A signal was delivered before the time limit expired and
224 before any of the selected events occurred.
226 The specified time limit is negative.
240 function call appeared in
242 This manual page was taken from
246 function first appeared in
249 The distinction between some of the fields in the
253 bitmasks is really not useful without STREAMS.
254 The fields are defined for compatibility with existing software.