Sat Oct 31 10:51:59 2020 UTC ()
Remove trailing whitespace.


(wiz)
diff -r1.51 -r1.52 src/lib/libc/sys/kqueue.2

cvs diff -r1.51 -r1.52 src/lib/libc/sys/kqueue.2 (switch to unified diff)

--- src/lib/libc/sys/kqueue.2 2020/10/31 01:08:31 1.51
+++ src/lib/libc/sys/kqueue.2 2020/10/31 10:51:59 1.52
@@ -1,782 +1,782 @@ @@ -1,782 +1,782 @@
1.\" $NetBSD: kqueue.2,v 1.51 2020/10/31 01:08:31 christos Exp $ 1.\" $NetBSD: kqueue.2,v 1.52 2020/10/31 10:51:59 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 2000 Jonathan Lemon 3.\" Copyright (c) 2000 Jonathan Lemon
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" Copyright (c) 2001, 2002, 2003 The NetBSD Foundation, Inc. 6.\" Copyright (c) 2001, 2002, 2003 The NetBSD Foundation, Inc.
7.\" All rights reserved. 7.\" All rights reserved.
8.\" 8.\"
9.\" Portions of this documentation is derived from text contributed by 9.\" Portions of this documentation is derived from text contributed by
10.\" Luke Mewburn. 10.\" Luke Mewburn.
11.\" 11.\"
12.\" Redistribution and use in source and binary forms, with or without 12.\" Redistribution and use in source and binary forms, with or without
13.\" modification, are permitted provided that the following conditions 13.\" modification, are permitted provided that the following conditions
14.\" are met: 14.\" are met:
15.\" 1. Redistributions of source code must retain the above copyright 15.\" 1. Redistributions of source code must retain the above copyright
16.\" notice, this list of conditions and the following disclaimer. 16.\" notice, this list of conditions and the following disclaimer.
17.\" 2. Redistributions in binary form must reproduce the above copyright 17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\" notice, this list of conditions and the following disclaimer in the 18.\" notice, this list of conditions and the following disclaimer in the
19.\" documentation and/or other materials provided with the distribution. 19.\" documentation and/or other materials provided with the distribution.
20.\" 20.\"
21.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND 21.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE. 31.\" SUCH DAMAGE.
32.\" 32.\"
33.\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.22 2001/06/27 19:55:57 dd Exp $ 33.\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.22 2001/06/27 19:55:57 dd Exp $
34.\" 34.\"
35.Dd October 30, 2020 35.Dd October 30, 2020
36.Dt KQUEUE 2 36.Dt KQUEUE 2
37.Os 37.Os
38.Sh NAME 38.Sh NAME
39.Nm kqueue , 39.Nm kqueue ,
40.Nm kqueue1 , 40.Nm kqueue1 ,
41.Nm kevent , 41.Nm kevent ,
42.Nm EV_SET 42.Nm EV_SET
43.Nd kernel event notification mechanism 43.Nd kernel event notification mechanism
44.Sh LIBRARY 44.Sh LIBRARY
45.Lb libc 45.Lb libc
46.Sh SYNOPSIS 46.Sh SYNOPSIS
47.In sys/event.h 47.In sys/event.h
48.In sys/time.h 48.In sys/time.h
49.Ft int 49.Ft int
50.Fn kqueue "void" 50.Fn kqueue "void"
51.Ft int 51.Ft int
52.Fn kqueue1 "int flags" 52.Fn kqueue1 "int flags"
53.Ft int 53.Ft int
54.Fn kevent "int kq" "const struct kevent *changelist" "size_t nchanges" "struct kevent *eventlist" "size_t nevents" "const struct timespec *timeout" 54.Fn kevent "int kq" "const struct kevent *changelist" "size_t nchanges" "struct kevent *eventlist" "size_t nevents" "const struct timespec *timeout"
55.Fn EV_SET "&kev" ident filter flags fflags data udata 55.Fn EV_SET "&kev" ident filter flags fflags data udata
56.Sh DESCRIPTION 56.Sh DESCRIPTION
57The 57The
58.Fn kqueue 58.Fn kqueue
59system call 59system call
60provides a generic method of notifying the user when an event 60provides a generic method of notifying the user when an event
61happens or a condition holds, based on the results of small 61happens or a condition holds, based on the results of small
62pieces of kernel code termed filters. 62pieces of kernel code termed filters.
63A kevent is identified by the (ident, filter) pair; there may only 63A kevent is identified by the (ident, filter) pair; there may only
64be one unique kevent per kqueue. 64be one unique kevent per kqueue.
65.Pp 65.Pp
66The filter is executed upon the initial registration of a kevent 66The filter is executed upon the initial registration of a kevent
67in order to detect whether a preexisting condition is present, and is also 67in order to detect whether a preexisting condition is present, and is also
68executed whenever an event is passed to the filter for evaluation. 68executed whenever an event is passed to the filter for evaluation.
69If the filter determines that the condition should be reported, 69If the filter determines that the condition should be reported,
70then the kevent is placed on the kqueue for the user to retrieve. 70then the kevent is placed on the kqueue for the user to retrieve.
71.Pp 71.Pp
72The filter is also run when the user attempts to retrieve the kevent 72The filter is also run when the user attempts to retrieve the kevent
73from the kqueue. 73from the kqueue.
74If the filter indicates that the condition that triggered 74If the filter indicates that the condition that triggered
75the event no longer holds, the kevent is removed from the kqueue and 75the event no longer holds, the kevent is removed from the kqueue and
76is not returned. 76is not returned.
77.Pp 77.Pp
78Multiple events which trigger the filter do not result in multiple 78Multiple events which trigger the filter do not result in multiple
79kevents being placed on the kqueue; instead, the filter will aggregate 79kevents being placed on the kqueue; instead, the filter will aggregate
80the events into a single struct kevent. 80the events into a single struct kevent.
81Calling 81Calling
82.Xr close 2 82.Xr close 2
83on a file descriptor will remove any kevents that reference the descriptor. 83on a file descriptor will remove any kevents that reference the descriptor.
84.Pp 84.Pp
85The 85The
86.Fn kqueue 86.Fn kqueue
87system call 87system call
88creates a new kernel event queue and returns a descriptor. 88creates a new kernel event queue and returns a descriptor.
89.Pp 89.Pp
90The 90The
91.Fn kqueue1 91.Fn kqueue1
92system call also allows to set the following 92system call also allows to set the following
93.Fa flags 93.Fa flags
94on the returned file descriptor: 94on the returned file descriptor:
95.Bl -column O_NONBLOCK -offset indent 95.Bl -column O_NONBLOCK -offset indent
96.It Dv O_CLOEXEC 96.It Dv O_CLOEXEC
97Set the close on exec property. 97Set the close on exec property.
98.It Dv O_NONBLOCK 98.It Dv O_NONBLOCK
99Set non-blocking I/O. 99Set non-blocking I/O.
100.It Dv O_NOSIGPIPE 100.It Dv O_NOSIGPIPE
101Return 101Return
102.Er EPIPE 102.Er EPIPE
103instead of raising 103instead of raising
104.Dv SIGPIPE . 104.Dv SIGPIPE .
105.El 105.El
106.Pp 106.Pp
107The queue is not inherited by a child created with 107The queue is not inherited by a child created with
108.Xr fork 2 . 108.Xr fork 2 .
109.\" However, if 109.\" However, if
110.\" .Xr rfork 2 110.\" .Xr rfork 2
111.\" is called without the 111.\" is called without the
112.\" .Dv RFFDG 112.\" .Dv RFFDG
113.\" flag, then the descriptor table is shared, 113.\" flag, then the descriptor table is shared,
114.\" which will allow sharing of the kqueue between two processes. 114.\" which will allow sharing of the kqueue between two processes.
115.Pp 115.Pp
116The 116The
117.Fn kevent 117.Fn kevent
118system call 118system call
119is used to register events with the queue, and return any pending 119is used to register events with the queue, and return any pending
120events to the user. 120events to the user.
121The 121The
122.Fa changelist 122.Fa changelist
123argument 123argument
124is a pointer to an array of 124is a pointer to an array of
125.Va kevent 125.Va kevent
126structures, as defined in 126structures, as defined in
127.In sys/event.h . 127.In sys/event.h .
128All changes contained in the 128All changes contained in the
129.Fa changelist 129.Fa changelist
130are applied before any pending events are read from the queue. 130are applied before any pending events are read from the queue.
131The 131The
132.Fa nchanges 132.Fa nchanges
133argument 133argument
134gives the size of 134gives the size of
135.Fa changelist . 135.Fa changelist .
136The 136The
137.Fa eventlist 137.Fa eventlist
138argument 138argument
139is a pointer to an array of kevent structures. 139is a pointer to an array of kevent structures.
140The  140The
141.Fa nevents 141.Fa nevents
142argument 142argument
143determines the size of 143determines the size of
144.Fa eventlist . 144.Fa eventlist .
145When 145When
146.Fa nevents 146.Fa nevents
147is zero, 147is zero,
148.Fn kevent 148.Fn kevent
149will return immediately even if there is a 149will return immediately even if there is a
150.Fa timeout 150.Fa timeout
151specified unlike 151specified unlike
152.Xr select 2 . 152.Xr select 2 .
153If 153If
154.Fa timeout 154.Fa timeout
155is a 155is a
156.No non- Ns Dv NULL 156.No non- Ns Dv NULL
157pointer, it specifies a maximum interval to wait 157pointer, it specifies a maximum interval to wait
158for an event, which will be interpreted as a 158for an event, which will be interpreted as a
159.Li struct timespec . 159.Li struct timespec .
160If 160If
161.Fa timeout 161.Fa timeout
162is a 162is a
163.Dv NULL 163.Dv NULL
164pointer, 164pointer,
165.Fn kevent 165.Fn kevent
166waits indefinitely. 166waits indefinitely.
167To effect a poll, the 167To effect a poll, the
168.Fa timeout 168.Fa timeout
169argument should be 169argument should be
170.No non- Ns Dv NULL , 170.No non- Ns Dv NULL ,
171pointing to a zero-valued 171pointing to a zero-valued
172.Xr timespec 3 172.Xr timespec 3
173structure. 173structure.
174The same array may be used for the 174The same array may be used for the
175.Fa changelist 175.Fa changelist
176and 176and
177.Fa eventlist . 177.Fa eventlist .
178.Pp 178.Pp
179The 179The
180.Fn EV_SET 180.Fn EV_SET
181macro is provided for ease of initializing a kevent structure. 181macro is provided for ease of initializing a kevent structure.
182This macro does not evaluate its parameters multiple times. 182This macro does not evaluate its parameters multiple times.
183.Pp 183.Pp
184The 184The
185.Va kevent 185.Va kevent
186structure is defined as: 186structure is defined as:
187.Bd -literal 187.Bd -literal
188struct kevent { 188struct kevent {
189 uintptr_t ident; /* identifier for this event */ 189 uintptr_t ident; /* identifier for this event */
190 uint32_t filter; /* filter for event */ 190 uint32_t filter; /* filter for event */
191 uint32_t flags; /* action flags for kqueue */ 191 uint32_t flags; /* action flags for kqueue */
192 uint32_t fflags; /* filter flag value */ 192 uint32_t fflags; /* filter flag value */
193 int64_t data; /* filter data value */ 193 int64_t data; /* filter data value */
194 void *udata; /* opaque user data identifier */ 194 void *udata; /* opaque user data identifier */
195}; 195};
196.Ed 196.Ed
197.Pp 197.Pp
198The fields of 198The fields of
199.Fa struct kevent 199.Fa struct kevent
200are: 200are:
201.Bl -tag -width "Fa filter" -offset indent 201.Bl -tag -width "Fa filter" -offset indent
202.It ident 202.It ident
203Value used to identify this event. 203Value used to identify this event.
204The exact interpretation is determined by the attached filter, 204The exact interpretation is determined by the attached filter,
205but often is a file descriptor. 205but often is a file descriptor.
206.It Fa filter 206.It Fa filter
207Identifies the kernel filter used to process this event. 207Identifies the kernel filter used to process this event.
208There are pre-defined system filters (which are described below), and 208There are pre-defined system filters (which are described below), and
209other filters may be added by kernel subsystems as necessary. 209other filters may be added by kernel subsystems as necessary.
210.It Fa flags 210.It Fa flags
211Actions to perform on the event. 211Actions to perform on the event.
212.It Fa fflags 212.It Fa fflags
213Filter-specific flags. 213Filter-specific flags.
214.It Fa data 214.It Fa data
215Filter-specific data value. 215Filter-specific data value.
216.It Fa udata 216.It Fa udata
217Opaque user-defined value passed through the kernel unchanged. 217Opaque user-defined value passed through the kernel unchanged.
218.El 218.El
219.Pp 219.Pp
220The 220The
221.Va flags 221.Va flags
222field can contain the following values: 222field can contain the following values:
223.Bl -tag -width XXXEV_ONESHOT -offset indent 223.Bl -tag -width XXXEV_ONESHOT -offset indent
224.It Dv EV_ADD 224.It Dv EV_ADD
225Adds the event to the kqueue. 225Adds the event to the kqueue.
226Re-adding an existing event will modify the parameters of the original 226Re-adding an existing event will modify the parameters of the original
227event, and not result in a duplicate entry. 227event, and not result in a duplicate entry.
228Adding an event automatically enables it, 228Adding an event automatically enables it,
229unless overridden by the EV_DISABLE flag. 229unless overridden by the EV_DISABLE flag.
230.It Dv EV_ENABLE 230.It Dv EV_ENABLE
231Permit 231Permit
232.Fn kevent 232.Fn kevent
233to return the event if it is triggered. 233to return the event if it is triggered.
234.It Dv EV_DISABLE 234.It Dv EV_DISABLE
235Disable the event so 235Disable the event so
236.Fn kevent 236.Fn kevent
237will not return it. 237will not return it.
238The filter itself is not disabled. 238The filter itself is not disabled.
239.It Dv EV_DISPATCH 239.It Dv EV_DISPATCH
240Disable the event source immediately after delivery of an event. 240Disable the event source immediately after delivery of an event.
241See 241See
242.Dv EV_DISABLE 242.Dv EV_DISABLE
243above. 243above.
244.It Dv EV_DELETE 244.It Dv EV_DELETE
245Removes the event from the kqueue. 245Removes the event from the kqueue.
246Events which are attached to file descriptors are automatically deleted 246Events which are attached to file descriptors are automatically deleted
247on the last close of the descriptor. 247on the last close of the descriptor.
248.It Dv EV_RECEIPT 248.It Dv EV_RECEIPT
249This flag is useful for making bulk changes to a kqueue without draining 249This flag is useful for making bulk changes to a kqueue without draining
250any pending events. 250any pending events.
251When passed as input, it forces 251When passed as input, it forces
252.Dv EV_ERROR 252.Dv EV_ERROR
253to always be returned. 253to always be returned.
254When a filter is successfully added the 254When a filter is successfully added the
255.Va data 255.Va data
256field will be zero. 256field will be zero.
257Note that if this flag is encountered and there is no remaining space in 257Note that if this flag is encountered and there is no remaining space in
258.Fa eventlist 258.Fa eventlist
259to hold the 259to hold the
260.Dv EV_ERROR 260.Dv EV_ERROR
261event, then subsequent changes will not get processed. 261event, then subsequent changes will not get processed.
262.It Dv EV_ONESHOT 262.It Dv EV_ONESHOT
263Causes the event to return only the first occurrence of the filter 263Causes the event to return only the first occurrence of the filter
264being triggered. 264being triggered.
265After the user retrieves the event from the kqueue, it is deleted. 265After the user retrieves the event from the kqueue, it is deleted.
266.It Dv EV_CLEAR 266.It Dv EV_CLEAR
267After the event is retrieved by the user, its state is reset. 267After the event is retrieved by the user, its state is reset.
268This is useful for filters which report state transitions 268This is useful for filters which report state transitions
269instead of the current state. 269instead of the current state.
270Note that some filters may automatically set this flag internally. 270Note that some filters may automatically set this flag internally.
271.It Dv EV_EOF 271.It Dv EV_EOF
272Filters may set this flag to indicate filter-specific EOF condition. 272Filters may set this flag to indicate filter-specific EOF condition.
273.It Dv EV_ERROR 273.It Dv EV_ERROR
274See 274See
275.Sx RETURN VALUES 275.Sx RETURN VALUES
276below. 276below.
277.El 277.El
278.Ss Filters 278.Ss Filters
279Filters are identified by a number. 279Filters are identified by a number.
280There are two types of filters; pre-defined filters which 280There are two types of filters; pre-defined filters which
281are described below, and third-party filters that may be added with 281are described below, and third-party filters that may be added with
282.Xr kfilter_register 9 282.Xr kfilter_register 9
283by kernel sub-systems, third-party device drivers, or loadable 283by kernel sub-systems, third-party device drivers, or loadable
284kernel modules. 284kernel modules.
285.Pp 285.Pp
286As a third-party filter is referenced by a well-known name instead 286As a third-party filter is referenced by a well-known name instead
287of a statically assigned number, two 287of a statically assigned number, two
288.Xr ioctl 2 Ns s 288.Xr ioctl 2 Ns s
289are supported on the file descriptor returned by 289are supported on the file descriptor returned by
290.Fn kqueue 290.Fn kqueue
291to map a filter name to a filter number, and vice-versa (passing 291to map a filter name to a filter number, and vice-versa (passing
292arguments in a structure described below): 292arguments in a structure described below):
293.Bl -tag -width KFILTER_BYFILTER -offset indent 293.Bl -tag -width KFILTER_BYFILTER -offset indent
294.It Dv KFILTER_BYFILTER 294.It Dv KFILTER_BYFILTER
295Map 295Map
296.Va filter 296.Va filter
297to 297to
298.Va name , 298.Va name ,
299which is of size 299which is of size
300.Va len . 300.Va len .
301.It Dv KFILTER_BYNAME 301.It Dv KFILTER_BYNAME
302Map 302Map
303.Va name 303.Va name
304to 304to
305.Va filter . 305.Va filter .
306.Va len 306.Va len
307is ignored. 307is ignored.
308.El 308.El
309.Pp 309.Pp
310The following structure is used to pass arguments in and out of the 310The following structure is used to pass arguments in and out of the
311.Xr ioctl 2 : 311.Xr ioctl 2 :
312.Bd -literal -offset indent 312.Bd -literal -offset indent
313struct kfilter_mapping { 313struct kfilter_mapping {
314 char *name; /* name to lookup or return */ 314 char *name; /* name to lookup or return */
315 size_t len; /* length of name */ 315 size_t len; /* length of name */
316 uint32_t filter; /* filter to lookup or return */ 316 uint32_t filter; /* filter to lookup or return */
317}; 317};
318.Ed 318.Ed
319.Pp 319.Pp
320The predefined system filters are listed below. 320The predefined system filters are listed below.
321Arguments may be passed to and from the filter via the 321Arguments may be passed to and from the filter via the
322.Va fflags 322.Va fflags
323and 323and
324.Va data 324.Va data
325fields in the kevent structure. 325fields in the kevent structure.
326.Pp 326.Pp
327The predefined system filters are: 327The predefined system filters are:
328.Bl -tag -width EVFILT_SIGNAL 328.Bl -tag -width EVFILT_SIGNAL
329.It Dv EVFILT_READ 329.It Dv EVFILT_READ
330Takes a descriptor as the identifier, and returns whenever 330Takes a descriptor as the identifier, and returns whenever
331there is data available to read. 331there is data available to read.
332The behavior of the filter is slightly different depending 332The behavior of the filter is slightly different depending
333on the descriptor type. 333on the descriptor type.
334.Bl -tag -width 2n 334.Bl -tag -width 2n
335.It Sockets 335.It Sockets
336Sockets which have previously been passed to 336Sockets which have previously been passed to
337.Xr listen 2 337.Xr listen 2
338return when there is an incoming connection pending. 338return when there is an incoming connection pending.
339.Va data 339.Va data
340contains the size of the listen backlog (i.e., the number of 340contains the size of the listen backlog (i.e., the number of
341connections ready to be accepted with 341connections ready to be accepted with
342.Xr accept 2 . ) 342.Xr accept 2 . )
343.Pp 343.Pp
344Other socket descriptors return when there is data to be read, 344Other socket descriptors return when there is data to be read,
345subject to the 345subject to the
346.Dv SO_RCVLOWAT 346.Dv SO_RCVLOWAT
347value of the socket buffer. 347value of the socket buffer.
348This may be overridden with a per-filter low water mark at the 348This may be overridden with a per-filter low water mark at the
349time the filter is added by setting the 349time the filter is added by setting the
350NOTE_LOWAT 350NOTE_LOWAT
351flag in 351flag in
352.Va fflags , 352.Va fflags ,
353and specifying the new low water mark in 353and specifying the new low water mark in
354.Va data . 354.Va data .
355On return, 355On return,
356.Va data 356.Va data
357contains the number of bytes in the socket buffer. 357contains the number of bytes in the socket buffer.
358.Pp 358.Pp
359If the read direction of the socket has shutdown, then the filter 359If the read direction of the socket has shutdown, then the filter
360also sets EV_EOF in 360also sets EV_EOF in
361.Va flags , 361.Va flags ,
362and returns the socket error (if any) in 362and returns the socket error (if any) in
363.Va fflags . 363.Va fflags .
364It is possible for EOF to be returned (indicating the connection is gone) 364It is possible for EOF to be returned (indicating the connection is gone)
365while there is still data pending in the socket buffer. 365while there is still data pending in the socket buffer.
366.It Vnodes 366.It Vnodes
367Returns when the file pointer is not at the end of file. 367Returns when the file pointer is not at the end of file.
368.Va data 368.Va data
369contains the offset from current position to end of file, 369contains the offset from current position to end of file,
370and may be negative. 370and may be negative.
371.\" .Pp 371.\" .Pp
372.\" This behavior is different from 372.\" This behavior is different from
373.\" .Xr poll 2 , 373.\" .Xr poll 2 ,
374.\" where read events are triggered for regular files unconditionally. 374.\" where read events are triggered for regular files unconditionally.
375.\" This event can be triggered unconditionally by setting the 375.\" This event can be triggered unconditionally by setting the
376.\" .Dv NOTE_FILE_POLL 376.\" .Dv NOTE_FILE_POLL
377.\" flag in 377.\" flag in
378.\" .Va fflags . 378.\" .Va fflags .
379.It "Fifos, Pipes" 379.It "Fifos, Pipes"
380Returns when there is data to read; 380Returns when there is data to read;
381.Va data 381.Va data
382contains the number of bytes available. 382contains the number of bytes available.
383.Pp 383.Pp
384When the last writer disconnects, the filter will set EV_EOF in 384When the last writer disconnects, the filter will set EV_EOF in
385.Va flags . 385.Va flags .
386This may be cleared by passing in EV_CLEAR, at which point the 386This may be cleared by passing in EV_CLEAR, at which point the
387filter will resume waiting for data to become available before 387filter will resume waiting for data to become available before
388returning. 388returning.
389.It "BPF devices" 389.It "BPF devices"
390Returns when the BPF buffer is full, the BPF timeout has expired, or 390Returns when the BPF buffer is full, the BPF timeout has expired, or
391when the BPF has 391when the BPF has
392.Dq immediate mode 392.Dq immediate mode
393enabled and there is any data to read; 393enabled and there is any data to read;
394.Va data 394.Va data
395.El 395.El
396.It Dv EVFILT_WRITE 396.It Dv EVFILT_WRITE
397Takes a descriptor as the identifier, and returns whenever 397Takes a descriptor as the identifier, and returns whenever
398it is possible to write to the descriptor. 398it is possible to write to the descriptor.
399For sockets, pipes, fifos, and ttys, 399For sockets, pipes, fifos, and ttys,
400.Va data 400.Va data
401will contain the amount of space remaining in the write buffer. 401will contain the amount of space remaining in the write buffer.
402The filter will set EV_EOF when the reader disconnects, and for 402The filter will set EV_EOF when the reader disconnects, and for
403the fifo case, this may be cleared by use of EV_CLEAR. 403the fifo case, this may be cleared by use of EV_CLEAR.
404Note that this filter is not supported for vnodes. 404Note that this filter is not supported for vnodes.
405.Pp 405.Pp
406For sockets, the low water mark and socket error handling is 406For sockets, the low water mark and socket error handling is
407identical to the EVFILT_READ case. 407identical to the EVFILT_READ case.
408.It Dv EVFILT_AIO 408.It Dv EVFILT_AIO
409This is not implemented in 409This is not implemented in
410.Nx . 410.Nx .
411.ig 411.ig
412The sigevent portion of the AIO request is filled in, with 412The sigevent portion of the AIO request is filled in, with
413.Va sigev_notify_kqueue 413.Va sigev_notify_kqueue
414containing the descriptor of the kqueue that the event should 414containing the descriptor of the kqueue that the event should
415be attached to, 415be attached to,
416.Va sigev_value 416.Va sigev_value
417containing the udata value, and 417containing the udata value, and
418.Va sigev_notify 418.Va sigev_notify
419set to SIGEV_EVENT. 419set to SIGEV_EVENT.
420When the aio_* function is called, the event will be registered 420When the aio_* function is called, the event will be registered
421with the specified kqueue, and the 421with the specified kqueue, and the
422.Va ident 422.Va ident
423argument set to the 423argument set to the
424.Fa struct aiocb 424.Fa struct aiocb
425returned by the aio_* function. 425returned by the aio_* function.
426The filter returns under the same conditions as aio_error. 426The filter returns under the same conditions as aio_error.
427.Pp 427.Pp
428Alternatively, a kevent structure may be initialized, with 428Alternatively, a kevent structure may be initialized, with
429.Va ident 429.Va ident
430containing the descriptor of the kqueue, and the 430containing the descriptor of the kqueue, and the
431address of the kevent structure placed in the 431address of the kevent structure placed in the
432.Va aio_lio_opcode 432.Va aio_lio_opcode
433field of the AIO request. 433field of the AIO request.
434However, this approach will not work on 434However, this approach will not work on
435architectures with 64-bit pointers, and should be considered deprecated. 435architectures with 64-bit pointers, and should be considered deprecated.
436.. 436..
437.It Dv EVFILT_VNODE 437.It Dv EVFILT_VNODE
438Takes a file descriptor as the identifier and the events to watch for in 438Takes a file descriptor as the identifier and the events to watch for in
439.Va fflags , 439.Va fflags ,
440and returns when one or more of the requested events occurs on the descriptor. 440and returns when one or more of the requested events occurs on the descriptor.
441The events to monitor are: 441The events to monitor are:
442.Bl -tag -width XXNOTE_RENAME 442.Bl -tag -width XXNOTE_RENAME
443.It Dv NOTE_DELETE 443.It Dv NOTE_DELETE
444.Xr unlink 2 444.Xr unlink 2
445was called on the file referenced by the descriptor. 445was called on the file referenced by the descriptor.
446.It Dv NOTE_WRITE 446.It Dv NOTE_WRITE
447A write occurred on the file referenced by the descriptor. 447A write occurred on the file referenced by the descriptor.
448.It Dv NOTE_EXTEND 448.It Dv NOTE_EXTEND
449The file referenced by the descriptor was extended. 449The file referenced by the descriptor was extended.
450.It Dv NOTE_ATTRIB 450.It Dv NOTE_ATTRIB
451The file referenced by the descriptor had its attributes changed. 451The file referenced by the descriptor had its attributes changed.
452.It Dv NOTE_LINK 452.It Dv NOTE_LINK
453The link count on the file changed. 453The link count on the file changed.
454.It Dv NOTE_RENAME 454.It Dv NOTE_RENAME
455The file referenced by the descriptor was renamed. 455The file referenced by the descriptor was renamed.
456.It Dv NOTE_REVOKE 456.It Dv NOTE_REVOKE
457Access to the file was revoked via 457Access to the file was revoked via
458.Xr revoke 2 458.Xr revoke 2
459or the underlying file system was unmounted. 459or the underlying file system was unmounted.
460.El 460.El
461.Pp 461.Pp
462On return, 462On return,
463.Va fflags 463.Va fflags
464contains the events which triggered the filter. 464contains the events which triggered the filter.
465.It Dv EVFILT_PROC 465.It Dv EVFILT_PROC
466Takes the process ID to monitor as the identifier and the events to watch for 466Takes the process ID to monitor as the identifier and the events to watch for
467in 467in
468.Va fflags , 468.Va fflags ,
469and returns when the process performs one or more of the requested events. 469and returns when the process performs one or more of the requested events.
470If a process can normally see another process, it can attach an event to it. 470If a process can normally see another process, it can attach an event to it.
471The events to monitor are: 471The events to monitor are:
472.Bl -tag -width XXNOTE_TRACKERR 472.Bl -tag -width XXNOTE_TRACKERR
473.It Dv NOTE_EXIT 473.It Dv NOTE_EXIT
474The process has exited. 474The process has exited.
475The exit code of the process is stored in 475The exit code of the process is stored in
476.Va data . 476.Va data .
477.It Dv NOTE_FORK 477.It Dv NOTE_FORK
478The process has called 478The process has called
479.Xr fork 2 . 479.Xr fork 2 .
480.It Dv NOTE_EXEC 480.It Dv NOTE_EXEC
481The process has executed a new process via 481The process has executed a new process via
482.Xr execve 2 482.Xr execve 2
483or similar call. 483or similar call.
484.It Dv NOTE_TRACK 484.It Dv NOTE_TRACK
485Follow a process across 485Follow a process across
486.Xr fork 2 486.Xr fork 2
487calls. 487calls.
488The parent process will return with NOTE_TRACK set in the 488The parent process will return with NOTE_TRACK set in the
489.Va fflags 489.Va fflags
490field, while the child process will return with NOTE_CHILD set in 490field, while the child process will return with NOTE_CHILD set in
491.Va fflags 491.Va fflags
492and the parent PID in 492and the parent PID in
493.Va data . 493.Va data .
494.It Dv NOTE_TRACKERR 494.It Dv NOTE_TRACKERR
495This flag is returned if the system was unable to attach an event to 495This flag is returned if the system was unable to attach an event to
496the child process, usually due to resource limitations. 496the child process, usually due to resource limitations.
497.El 497.El
498.Pp 498.Pp
499On return, 499On return,
500.Va fflags 500.Va fflags
501contains the events which triggered the filter. 501contains the events which triggered the filter.
502.It Dv EVFILT_SIGNAL 502.It Dv EVFILT_SIGNAL
503Takes the signal number to monitor as the identifier and returns 503Takes the signal number to monitor as the identifier and returns
504when the given signal is delivered to the current process. 504when the given signal is delivered to the current process.
505This coexists with the 505This coexists with the
506.Xr signal 3 506.Xr signal 3
507and 507and
508.Xr sigaction 2 508.Xr sigaction 2
509facilities, and has a lower precedence. 509facilities, and has a lower precedence.
510The filter will record 510The filter will record
511all attempts to deliver a signal to a process, even if the signal has 511all attempts to deliver a signal to a process, even if the signal has
512been marked as SIG_IGN. 512been marked as SIG_IGN.
513Event notification happens after normal signal delivery processing. 513Event notification happens after normal signal delivery processing.
514.Va data 514.Va data
515returns the number of times the signal has occurred since the last call to 515returns the number of times the signal has occurred since the last call to
516.Fn kevent . 516.Fn kevent .
517This filter automatically sets the EV_CLEAR flag internally. 517This filter automatically sets the EV_CLEAR flag internally.
518.It Dv EVFILT_TIMER 518.It Dv EVFILT_TIMER
519Establishes an arbitrary timer identified by 519Establishes an arbitrary timer identified by
520.Va ident . 520.Va ident .
521When adding a timer, 521When adding a timer,
522.Va data 522.Va data
523specifies the timeout period in milliseconds. 523specifies the timeout period in milliseconds.
524The timer will be periodic unless EV_ONESHOT is specified. 524The timer will be periodic unless EV_ONESHOT is specified.
525On return, 525On return,
526.Va data 526.Va data
527contains the number of times the timeout has expired since the last call to 527contains the number of times the timeout has expired since the last call to
528.Fn kevent . 528.Fn kevent .
529This filter automatically sets the EV_CLEAR flag internally. 529This filter automatically sets the EV_CLEAR flag internally.
530.It Dv EVFILT_FS 530.It Dv EVFILT_FS
531Establishes a file system monitor. 531Establishes a file system monitor.
532Currently it only monitors file system mount and unmount actions. 532Currently it only monitors file system mount and unmount actions.
533.It Dv EVFILT_USER 533.It Dv EVFILT_USER
534Establishes a user event identified by 534Establishes a user event identified by
535.Va ident 535.Va ident
536which is not associated with any kernel mechanism but is triggered by 536which is not associated with any kernel mechanism but is triggered by
537user level code. 537user level code.
538The lower 24 bits of the 538The lower 24 bits of the
539.Va fflags 539.Va fflags
540may be used for user defined flags and manipulated using the following: 540may be used for user defined flags and manipulated using the following:
541.Bl -tag -width "Dv NOTE_FFLAGSMASK" 541.Bl -tag -width "Dv NOTE_FFLAGSMASK"
542.It Dv NOTE_FFNOP 542.It Dv NOTE_FFNOP
543Ignore the input 543Ignore the input
544.Va fflags . 544.Va fflags .
545.It Dv NOTE_FFAND 545.It Dv NOTE_FFAND
546Bitwise AND 546Bitwise AND
547.Va fflags . 547.Va fflags .
548.It Dv NOTE_FFOR 548.It Dv NOTE_FFOR
549Bitwise OR 549Bitwise OR
550.Va fflags . 550.Va fflags .
551.It Dv NOTE_FFCOPY 551.It Dv NOTE_FFCOPY
552Copy 552Copy
553.Va fflags . 553.Va fflags .
554.It Dv NOTE_FFCTRLMASK 554.It Dv NOTE_FFCTRLMASK
555Control mask for 555Control mask for
556.Va fflags . 556.Va fflags .
557.It Dv NOTE_FFLAGSMASK 557.It Dv NOTE_FFLAGSMASK
558User defined flag mask for 558User defined flag mask for
559.Va fflags . 559.Va fflags .
560.El 560.El
561.Pp 561.Pp
562A user event is triggered for output with the following: 562A user event is triggered for output with the following:
563.Bl -tag -width "Dv NOTE_FFLAGSMASK" 563.Bl -tag -width "Dv NOTE_FFLAGSMASK"
564.It Dv NOTE_TRIGGER 564.It Dv NOTE_TRIGGER
565Cause the event to be triggered. 565Cause the event to be triggered.
566.El 566.El
567.Pp 567.Pp
568On return, 568On return,
569.Va fflags 569.Va fflags
570contains the users defined flags in the lower 24 bits. 570contains the users defined flags in the lower 24 bits.
571.El 571.El
572.Sh CANCELLATION BEHAVIOUR 572.Sh CANCELLATION BEHAVIOUR
573If 573If
574.Fa nevents 574.Fa nevents
575is non-zero, i.e., the function is potentially blocking, the call 575is non-zero, i.e., the function is potentially blocking, the call
576is a cancellation point. 576is a cancellation point.
577Otherwise, i.e., if 577Otherwise, i.e., if
578.Fa nevents 578.Fa nevents
579is zero, the call is not cancellable. 579is zero, the call is not cancellable.
580Cancellation can only occur before any changes are made to the kqueue, 580Cancellation can only occur before any changes are made to the kqueue,
581or when the call was blocked and no changes to the queue were requested. 581or when the call was blocked and no changes to the queue were requested.
582.Sh RETURN VALUES 582.Sh RETURN VALUES
583The 583The
584.Fn kqueue 584.Fn kqueue
585system call 585system call
586creates a new kernel event queue and returns a file descriptor. 586creates a new kernel event queue and returns a file descriptor.
587If there was an error creating the kernel event queue, a value of \-1 is 587If there was an error creating the kernel event queue, a value of \-1 is
588returned and 588returned and
589.Dv errno 589.Dv errno
590is set. 590is set.
591.Pp 591.Pp
592The 592The
593.Fn kevent 593.Fn kevent
594system call 594system call
595returns the number of events placed in the 595returns the number of events placed in the
596.Fa eventlist , 596.Fa eventlist ,
597up to the value given by 597up to the value given by
598.Fa nevents . 598.Fa nevents .
599If an error occurs while processing an element of the 599If an error occurs while processing an element of the
600.Fa changelist 600.Fa changelist
601and there is enough room in the 601and there is enough room in the
602.Fa eventlist , 602.Fa eventlist ,
603then the event will be placed in the 603then the event will be placed in the
604.Fa eventlist 604.Fa eventlist
605with 605with
606.Dv EV_ERROR 606.Dv EV_ERROR
607set in 607set in
608.Va flags 608.Va flags
609and the system error in 609and the system error in
610.Va data . 610.Va data .
611Otherwise, 611Otherwise,
612.Dv \-1 612.Dv \-1
613will be returned, and 613will be returned, and
614.Dv errno 614.Dv errno
615will be set to indicate the error condition. 615will be set to indicate the error condition.
616If the time limit expires, then 616If the time limit expires, then
617.Fn kevent 617.Fn kevent
618returns 0. 618returns 0.
619.Sh EXAMPLES 619.Sh EXAMPLES
620The following example program monitors a file (provided to it as the first 620The following example program monitors a file (provided to it as the first
621argument) and prints information about some common events it receives 621argument) and prints information about some common events it receives
622notifications for: 622notifications for:
623.Bd -literal -offset indent 623.Bd -literal -offset indent
624#include <sys/types.h> 624#include <sys/types.h>
625#include <sys/event.h> 625#include <sys/event.h>
626#include <sys/time.h> 626#include <sys/time.h>
627#include <stdio.h> 627#include <stdio.h>
628#include <unistd.h> 628#include <unistd.h>
629#include <stdlib.h> 629#include <stdlib.h>
630#include <fcntl.h> 630#include <fcntl.h>
631#include <err.h> 631#include <err.h>
632 632
633int 633int
634main(int argc, char *argv[]) 634main(int argc, char *argv[])
635{ 635{
636 int fd, kq, nev; 636 int fd, kq, nev;
637 struct kevent ev; 637 struct kevent ev;
638 static const struct timespec tout = { 1, 0 }; 638 static const struct timespec tout = { 1, 0 };
639 639
640 if ((fd = open(argv[1], O_RDONLY)) == -1) 640 if ((fd = open(argv[1], O_RDONLY)) == -1)
641 err(1, "Cannot open `%s'", argv[1]); 641 err(1, "Cannot open `%s'", argv[1]);
642 642
643 if ((kq = kqueue()) == -1) 643 if ((kq = kqueue()) == -1)
644 err(1, "Cannot create kqueue"); 644 err(1, "Cannot create kqueue");
645 645
646 EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, 646 EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
647 NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK| 647 NOTE_DELETE|NOTE_WRITE|NOTE_EXTEND|NOTE_ATTRIB|NOTE_LINK|
648 NOTE_RENAME|NOTE_REVOKE, 0, 0); 648 NOTE_RENAME|NOTE_REVOKE, 0, 0);
649 if (kevent(kq, &ev, 1, NULL, 0, &tout) == -1) 649 if (kevent(kq, &ev, 1, NULL, 0, &tout) == -1)
650 err(1, "kevent"); 650 err(1, "kevent");
651 for (;;) { 651 for (;;) {
652 nev = kevent(kq, NULL, 0, &ev, 1, &tout); 652 nev = kevent(kq, NULL, 0, &ev, 1, &tout);
653 if (nev == -1) 653 if (nev == -1)
654 err(1, "kevent"); 654 err(1, "kevent");
655 if (nev == 0) 655 if (nev == 0)
656 continue; 656 continue;
657 if (ev.fflags & NOTE_DELETE) { 657 if (ev.fflags & NOTE_DELETE) {
658 printf("deleted "); 658 printf("deleted ");
659 ev.fflags &= ~NOTE_DELETE; 659 ev.fflags &= ~NOTE_DELETE;
660 } 660 }
661 if (ev.fflags & NOTE_WRITE) { 661 if (ev.fflags & NOTE_WRITE) {
662 printf("written "); 662 printf("written ");
663 ev.fflags &= ~NOTE_WRITE; 663 ev.fflags &= ~NOTE_WRITE;
664 } 664 }
665 if (ev.fflags & NOTE_EXTEND) { 665 if (ev.fflags & NOTE_EXTEND) {
666 printf("extended "); 666 printf("extended ");
667 ev.fflags &= ~NOTE_EXTEND; 667 ev.fflags &= ~NOTE_EXTEND;
668 } 668 }
669 if (ev.fflags & NOTE_ATTRIB) { 669 if (ev.fflags & NOTE_ATTRIB) {
670 printf("chmod/chown/utimes "); 670 printf("chmod/chown/utimes ");
671 ev.fflags &= ~NOTE_ATTRIB; 671 ev.fflags &= ~NOTE_ATTRIB;
672 } 672 }
673 if (ev.fflags & NOTE_LINK) { 673 if (ev.fflags & NOTE_LINK) {
674 printf("hardlinked "); 674 printf("hardlinked ");
675 ev.fflags &= ~NOTE_LINK; 675 ev.fflags &= ~NOTE_LINK;
676 } 676 }
677 if (ev.fflags & NOTE_RENAME) { 677 if (ev.fflags & NOTE_RENAME) {
678 printf("renamed "); 678 printf("renamed ");
679 ev.fflags &= ~NOTE_RENAME; 679 ev.fflags &= ~NOTE_RENAME;
680 } 680 }
681 if (ev.fflags & NOTE_REVOKE) { 681 if (ev.fflags & NOTE_REVOKE) {
682 printf("revoked "); 682 printf("revoked ");
683 ev.fflags &= ~NOTE_REVOKE; 683 ev.fflags &= ~NOTE_REVOKE;
684 } 684 }
685 printf("\\n"); 685 printf("\\n");
686 if (ev.fflags) 686 if (ev.fflags)
687 warnx("unknown event 0x%x\\n", ev.fflags); 687 warnx("unknown event 0x%x\\n", ev.fflags);
688 } 688 }
689} 689}
690.Ed 690.Ed
691.Sh ERRORS 691.Sh ERRORS
692The 692The
693.Fn kqueue 693.Fn kqueue
694function fails if: 694function fails if:
695.Bl -tag -width Er 695.Bl -tag -width Er
696.It Bq Er EMFILE 696.It Bq Er EMFILE
697The per-process descriptor table is full. 697The per-process descriptor table is full.
698.It Bq Er ENFILE 698.It Bq Er ENFILE
699The system file table is full. 699The system file table is full.
700.It Bq Er ENOMEM 700.It Bq Er ENOMEM
701The kernel failed to allocate enough memory for the kernel queue. 701The kernel failed to allocate enough memory for the kernel queue.
702.El 702.El
703.Pp 703.Pp
704The 704The
705.Fn kevent 705.Fn kevent
706function fails if: 706function fails if:
707.Bl -tag -width Er 707.Bl -tag -width Er
708.It Bq Er EACCES 708.It Bq Er EACCES
709The process does not have permission to register a filter. 709The process does not have permission to register a filter.
710.It Bq Er EBADF 710.It Bq Er EBADF
711The specified descriptor is invalid. 711The specified descriptor is invalid.
712.It Bq Er EFAULT 712.It Bq Er EFAULT
713There was an error reading or writing the 713There was an error reading or writing the
714.Va kevent 714.Va kevent
715structure. 715structure.
716.It Bq Er EINTR 716.It Bq Er EINTR
717A signal was delivered before the timeout expired and before any 717A signal was delivered before the timeout expired and before any
718events were placed on the kqueue for return. 718events were placed on the kqueue for return.
719All changes contained in the 719All changes contained in the
720.Fa changelist 720.Fa changelist
721are applied before returning this error. 721are applied before returning this error.
722.It Bq Er EINVAL 722.It Bq Er EINVAL
723The specified time limit or filter is invalid. 723The specified time limit or filter is invalid.
724.It Bq Er ENOENT 724.It Bq Er ENOENT
725The event could not be found to be modified or deleted. 725The event could not be found to be modified or deleted.
726.It Bq Er ENOMEM 726.It Bq Er ENOMEM
727No memory was available to register the event. 727No memory was available to register the event.
728.It Bq Er EOPNOTSUPP 728.It Bq Er EOPNOTSUPP
729This type of file descriptor is not supported for 729This type of file descriptor is not supported for
730.Fn kevent 730.Fn kevent
731operations. 731operations.
732.It Bq Er ESRCH 732.It Bq Er ESRCH
733The specified process to attach to does not exist. 733The specified process to attach to does not exist.
734.El 734.El
735.Sh SEE ALSO 735.Sh SEE ALSO
736.\" .Xr aio_error 2 , 736.\" .Xr aio_error 2 ,
737.\" .Xr aio_read 2 , 737.\" .Xr aio_read 2 ,
738.\" .Xr aio_return 2 , 738.\" .Xr aio_return 2 ,
739.Xr fork 2 , 739.Xr fork 2 ,
740.Xr ioctl 2 , 740.Xr ioctl 2 ,
741.Xr listen 2 , 741.Xr listen 2 ,
742.Xr poll 2 , 742.Xr poll 2 ,
743.Xr read 2 , 743.Xr read 2 ,
744.Xr select 2 , 744.Xr select 2 ,
745.Xr sigaction 2 , 745.Xr sigaction 2 ,
746.Xr unlink 2 , 746.Xr unlink 2 ,
747.Xr write 2 , 747.Xr write 2 ,
748.Xr signal 3 , 748.Xr signal 3 ,
749.Xr timespec 3 , 749.Xr timespec 3 ,
750.Xr kfilter_register 9 , 750.Xr kfilter_register 9 ,
751.Xr knote 9 751.Xr knote 9
752.Rs 752.Rs
753.%A Jonathan Lemon 753.%A Jonathan Lemon
754.%T "Kqueue: A Generic and Scalable Event Notification Facility" 754.%T "Kqueue: A Generic and Scalable Event Notification Facility"
755.%I USENIX Association 755.%I USENIX Association
756.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference 756.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference
757.%D June 25-30, 2001 757.%D June 25-30, 2001
758.%U http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf 758.%U http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf
759.Re 759.Re
760.Sh HISTORY 760.Sh HISTORY
761The 761The
762.Fn kqueue 762.Fn kqueue
763and 763and
764.Fn kevent 764.Fn kevent
765functions first appeared in 765functions first appeared in
766.Fx 4.1 , 766.Fx 4.1 ,
767and then in 767and then in
768.Nx 2.0 . 768.Nx 2.0 .
769The 769The
770.Fn kqueue1 770.Fn kqueue1
771function first appeared in 771function first appeared in
772.Nx 6.0 . 772.Nx 6.0 .
773.Pp 773.Pp
774The 774The
775.Fn EV_SET 775.Fn EV_SET
776macro was protected from evaluating multiple times the first argument in 776macro was protected from evaluating multiple times the first argument in
777.Nx 8.0 . 777.Nx 8.0 .
778.Pp 778.Pp
779The 779The
780.Va udata 780.Va udata
781type was changed from intptr_t to void * in 781type was changed from intptr_t to void * in
782.Nx 10.0 . 782.Nx 10.0 .