2 .\" Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 .\" @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 .\" This file contains Original Code and/or Modifications of Original Code
7 .\" as defined in and that are subject to the Apple Public Source License
8 .\" Version 2.0 (the 'License'). You may not use this file except in
9 .\" compliance with the License. Please obtain a copy of the License at
10 .\" http://www.opensource.apple.com/apsl/ and read it before using this
13 .\" The Original Code and all software distributed under the License are
14 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 .\" Please see the License for the specific language governing rights and
19 .\" limitations under the License.
21 .\" @APPLE_OSREFERENCE_LICENSE_HEADER_END@
24 .\" Copyright (c) 1996 Charles M. Hannum. All rights reserved.
26 .\" Redistribution and use in source and binary forms, with or without
27 .\" modification, are permitted provided that the following conditions
29 .\" 1. Redistributions of source code must retain the above copyright
30 .\" notice, this list of conditions and the following disclaimer.
31 .\" 2. Redistributions in binary form must reproduce the above copyright
32 .\" notice, this list of conditions and the following disclaimer in the
33 .\" documentation and/or other materials provided with the distribution.
34 .\" 3. All advertising materials mentioning features or use of this software
35 .\" must display the following acknowledgement:
36 .\" This product includes software developed by Charles M. Hannum.
37 .\" 4. The name of the author may not be used to endorse or promote products
38 .\" derived from this software without specific prior written permission.
40 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
41 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
44 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
49 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 .Nd synchronous I/O multiplexing
60 .Fn poll "struct pollfd *fds" "nfds_t nfds" "int timeout"
63 examines a set of file descriptors to see if some of them are ready for
64 I/O or if certain events have occurred on them.
67 argument is a pointer to an array of pollfd structures as defined in
71 argument determines the size of the
76 int fd; /* file descriptor */
77 short events; /* events to look for */
78 short revents; /* events returned */
85 .Bl -tag -width XXXrevents
87 File descriptor to poll.
89 Events to poll for. (See below.)
91 Events which may occur or have occurred. (See below.)
98 have the following bits:
99 .Bl -tag -width XXXPOLLWRNORM
101 Data other than high priority data may be read without blocking.
102 This is equivalent to ( POLLRDNORM | POLLRDBAND ).
104 Normal data may be read without blocking.
106 Priority data may be read without blocking.
108 High priority data may be read without blocking.
111 Normal data may be written without blocking.
113 Priority data may be written without blocking.
115 An exceptional condition has occurred on the device or socket. This
116 flag is output only, and ignored if present in the input
120 The device or socket has been disconnected. This flag is output only,
121 and ignored if present in the input
127 are mutually exclusive and should never be present in the
129 bitmask at the same time.
131 The file descriptor is not open. This flag is output only, and ignored if present in the input
136 The distinction between normal, priority, and high-priority data is file type
141 is greater than zero, it specifies a maximum interval to
142 wait for any file descriptor to become ready, in milliseconds. If
146 will return without blocking. If the value of
148 is -1, the poll blocks indefinitely.
151 returns the number of descriptors that are ready for I/O, or -1 if an
152 error occured. If the time limit expires,
157 returns with an error,
158 including one due to an interrupted call,
161 array will be unmodified.
169 points outside the process's allocated address space.
171 A signal was delivered before the time limit expired and
172 before any of the selected events occurred.
176 argument is greater than OPEN_MAX, or the
178 argument is less than -1.
183 system call currently does not support devices.
196 function call appeared in