xref: /freebsd-13.1/lib/libc/sys/kqueue.2 (revision 4451bb5d)
1ad35a4c9SJonathan Lemon.\" Copyright (c) 2000 Jonathan Lemon
2ad35a4c9SJonathan Lemon.\" All rights reserved.
3ad35a4c9SJonathan Lemon.\"
4ad35a4c9SJonathan Lemon.\" Redistribution and use in source and binary forms, with or without
5ad35a4c9SJonathan Lemon.\" modification, are permitted provided that the following conditions
6ad35a4c9SJonathan Lemon.\" are met:
7ad35a4c9SJonathan Lemon.\" 1. Redistributions of source code must retain the above copyright
8ad35a4c9SJonathan Lemon.\"    notice, this list of conditions and the following disclaimer.
9ad35a4c9SJonathan Lemon.\" 2. Redistributions in binary form must reproduce the above copyright
10ad35a4c9SJonathan Lemon.\"    notice, this list of conditions and the following disclaimer in the
11ad35a4c9SJonathan Lemon.\"    documentation and/or other materials provided with the distribution.
12ad35a4c9SJonathan Lemon.\"
13ad35a4c9SJonathan Lemon.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND
14ad35a4c9SJonathan Lemon.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ad35a4c9SJonathan Lemon.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ad35a4c9SJonathan Lemon.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17ad35a4c9SJonathan Lemon.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ad35a4c9SJonathan Lemon.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ad35a4c9SJonathan Lemon.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ad35a4c9SJonathan Lemon.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ad35a4c9SJonathan Lemon.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ad35a4c9SJonathan Lemon.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ad35a4c9SJonathan Lemon.\" SUCH DAMAGE.
24ad35a4c9SJonathan Lemon.\"
25ad35a4c9SJonathan Lemon.\" $FreeBSD$
26ad35a4c9SJonathan Lemon.\"
27ad35a4c9SJonathan Lemon.Dd April 14, 2000
28ad35a4c9SJonathan Lemon.Dt KQUEUE 2
29ad35a4c9SJonathan Lemon.Os
30ad35a4c9SJonathan Lemon.Sh NAME
31*4451bb5dSJonathan Lemon.Nm kqueue ,
32*4451bb5dSJonathan Lemon.Nm kevent
33ad35a4c9SJonathan Lemon.Nd kernel event notification mechanism
34*4451bb5dSJonathan Lemon.Sh LIBRARY
35*4451bb5dSJonathan Lemon.Lb libc
36ad35a4c9SJonathan Lemon.Sh SYNOPSIS
37ad35a4c9SJonathan Lemon.Fd #include <sys/event.h>
38ad35a4c9SJonathan Lemon.Ft int
39ad35a4c9SJonathan Lemon.Fn kqueue "void"
40ad35a4c9SJonathan Lemon.Ft int
41ad35a4c9SJonathan Lemon.Fn kevent "int kq" "int nchanges" "struct kevent **changelist" \
42ad35a4c9SJonathan Lemon"int nevents" "struct kevent *eventlist" "struct timespec *timeout"
43ad35a4c9SJonathan Lemon.Sh DESCRIPTION
44ad35a4c9SJonathan Lemon.Fn kqueue
45ad35a4c9SJonathan Lemonprovides a generic method of notifying the user when an event
46ad35a4c9SJonathan Lemonhappens or a condition holds, based on the results of small
47ad35a4c9SJonathan Lemonpieces of kernel code termed filters.
48ad35a4c9SJonathan LemonAn kevent is identified by the (ident, filter) pair; there may only
49ad35a4c9SJonathan Lemonbe one unique kevent per kqueue.
50*4451bb5dSJonathan Lemon.Pp
51ad35a4c9SJonathan LemonThe filter is executed upon the initial registration of a kevent
52ad35a4c9SJonathan Lemonin order to detect a preexisting condition is present, and is also
53ad35a4c9SJonathan Lemonexecuted whenever an event is passed to the filter for evaluation.
54ad35a4c9SJonathan LemonIf the filter determines that the condition should be reported,
55ad35a4c9SJonathan Lemonthen the kevent is placed on the kqueue for the user to retrieve.
56*4451bb5dSJonathan Lemon.Pp
57ad35a4c9SJonathan LemonThe filter is also run when the user attempts to retrieve the kevent
58ad35a4c9SJonathan Lemonfrom the kqueue, and if the filter indicates the condition that triggered
59ad35a4c9SJonathan Lemonthe event no longer holds, the kevent is removed from the kqueue and
60ad35a4c9SJonathan Lemonis not returned.
61*4451bb5dSJonathan Lemon.Pp
62ad35a4c9SJonathan LemonMultiple events which trigger the filter do not result in multiple
63ad35a4c9SJonathan Lemonkevents being placed on the kqueue; instead, the filter will aggregate
64ad35a4c9SJonathan Lemonthe events into a single struct kevent.
65ad35a4c9SJonathan LemonCalling
66ad35a4c9SJonathan Lemon.Fn close
67ad35a4c9SJonathan Lemonon a file descriptor will remove any kevents that reference the descriptor.
68ad35a4c9SJonathan Lemon.Pp
69ad35a4c9SJonathan Lemon.Fn kqueue
70ad35a4c9SJonathan Lemoncreates a new kernel event queue and returns a descriptor.
71ad35a4c9SJonathan Lemon.Pp
72ad35a4c9SJonathan Lemon.Fn kevent
73ad35a4c9SJonathan Lemonis used to register events with the queue, and return any pending
74ad35a4c9SJonathan Lemonevents to the user.
75ad35a4c9SJonathan Lemon.Fa changelist
76ad35a4c9SJonathan Lemonis a pointer to an array of pointers to
77ad35a4c9SJonathan Lemon.Va kevent
78ad35a4c9SJonathan Lemonstructures, as defined in
79ad35a4c9SJonathan Lemon.Aq Pa event.h .
80ad35a4c9SJonathan LemonAll changes contained in the
81ad35a4c9SJonathan Lemon.Fa changelist
82ad35a4c9SJonathan Lemonare applied before any pending events are read from the queue.
83ad35a4c9SJonathan Lemon.Fa nchanges
84ad35a4c9SJonathan Lemongives the size of
85ad35a4c9SJonathan Lemon.Fa changelist .
86ad35a4c9SJonathan Lemon.Fa eventlist
87ad35a4c9SJonathan Lemonis a pointer to an array of kevent structures.
88ad35a4c9SJonathan Lemon.Fa nevents
89ad35a4c9SJonathan Lemondetermines the size of
90ad35a4c9SJonathan Lemon.Fa eventlist .
91ad35a4c9SJonathan LemonIf
92ad35a4c9SJonathan Lemon.Fa timeout
93ad35a4c9SJonathan Lemonis a non-NULL pointer, it specifies a maximum interval to wait
94ad35a4c9SJonathan Lemonfor an event.  If
95ad35a4c9SJonathan Lemon.Fa timeout
96ad35a4c9SJonathan Lemonis a NULL pointer,
97ad35a4c9SJonathan Lemon.Fn kevent
98ad35a4c9SJonathan Lemonwaits indefinitely.  To effect a poll, the
99ad35a4c9SJonathan Lemon.Fa timeout
100ad35a4c9SJonathan Lemonargument should be non-NULL, pointing to a zero-valued
101ad35a4c9SJonathan Lemon.Va timespec
102ad35a4c9SJonathan Lemonstructure.
103ad35a4c9SJonathan Lemon.Pp
104ad35a4c9SJonathan LemonThe
105ad35a4c9SJonathan Lemon.Va kevent
106ad35a4c9SJonathan Lemonstructure is defined as:
107ad35a4c9SJonathan Lemon.Bd -literal
108ad35a4c9SJonathan Lemonstruct kevent {
109ad35a4c9SJonathan Lemon	uintptr_t ident;	/* identifier for this event */
110ad35a4c9SJonathan Lemon	short	  filter;	/* filter for event */
111ad35a4c9SJonathan Lemon	u_short	  flags;	/* action flags for kqueue */
112ad35a4c9SJonathan Lemon	u_int	  fflags;	/* filter flag value */
113ad35a4c9SJonathan Lemon	intptr_t  data;		/* filter data value */
114ad35a4c9SJonathan Lemon	void	  *udata;	/* opaque user data identifier */
115ad35a4c9SJonathan Lemon};
116ad35a4c9SJonathan Lemon.Ed
117ad35a4c9SJonathan Lemon.Pp
118ad35a4c9SJonathan LemonThe fields of
119ad35a4c9SJonathan Lemon.Fa struct kevent
120ad35a4c9SJonathan Lemonare:
121ad35a4c9SJonathan Lemon.Bl -tag -width XXXfilter
122ad35a4c9SJonathan Lemon.It ident
123ad35a4c9SJonathan LemonValue used to identify this event.
124ad35a4c9SJonathan LemonThe exact interpretation is determined by the attached filter,
125ad35a4c9SJonathan Lemonbut often is a file descriptor.
126ad35a4c9SJonathan Lemon.It filter
127ad35a4c9SJonathan LemonIdentifies the kernel filter used to process this event.  The pre-defined
128ad35a4c9SJonathan Lemonsystem filters are described below.
129ad35a4c9SJonathan Lemon.It flags
130ad35a4c9SJonathan LemonActions to perform on the event.
131ad35a4c9SJonathan Lemon.It fflags
132ad35a4c9SJonathan LemonFilter-specific flags.
133ad35a4c9SJonathan Lemon.It data
134ad35a4c9SJonathan LemonFilter-specific data value.
135ad35a4c9SJonathan Lemon.It udata
136ad35a4c9SJonathan LemonOpaque user-defined value passed through the kernel unchanged.
137ad35a4c9SJonathan Lemon.El
138ad35a4c9SJonathan Lemon.Pp
139ad35a4c9SJonathan LemonThe
140ad35a4c9SJonathan Lemon.Va flags
141ad35a4c9SJonathan Lemonfield can contain the following values:
142ad35a4c9SJonathan Lemon.Bl -tag -width XXXEV_ONESHOT
143ad35a4c9SJonathan Lemon.It EV_ADD
144ad35a4c9SJonathan LemonAdds the event to the kqueue.  Re-adding an existing event
145ad35a4c9SJonathan Lemonwill modify the parameters of the original event, and not result
146ad35a4c9SJonathan Lemonin a duplicate entry.  Adding an event automatically enables it,
147ad35a4c9SJonathan Lemonunless overridden by the EV_DISABLE flag.
148ad35a4c9SJonathan Lemon.It EV_ENABLE
149ad35a4c9SJonathan LemonPermit
150ad35a4c9SJonathan Lemon.Fn kevent
151ad35a4c9SJonathan Lemonto return the event if it is triggered.
152ad35a4c9SJonathan Lemon.It EV_DISABLE
153ad35a4c9SJonathan LemonDisable the event so
154ad35a4c9SJonathan Lemon.Fn kevent
155ad35a4c9SJonathan Lemonwill not return it.  The filter itself is not disabled.
156ad35a4c9SJonathan Lemon.It EV_DELETE
157ad35a4c9SJonathan LemonRemoves the event from the kqueue.  Events which are attached to
158ad35a4c9SJonathan Lemonfile descriptors are automatically deleted on the last close of
159ad35a4c9SJonathan Lemonthe descriptor.
160ad35a4c9SJonathan Lemon.It EV_ONESHOT
161ad35a4c9SJonathan LemonCauses the event to return only the first occurrence of the filter
162ad35a4c9SJonathan Lemonbeing triggered.  After the user retrieves the event from the kqueue,
163ad35a4c9SJonathan Lemonit is deleted.
164ad35a4c9SJonathan Lemon.It EV_CLEAR
165ad35a4c9SJonathan LemonAfter the event is retrieved by the user, its state is reset.
166ad35a4c9SJonathan LemonThis is useful for filters which report state transitions
167ad35a4c9SJonathan Lemoninstead of the current state.  Note that some filters may automatically
168ad35a4c9SJonathan Lemonset this flag internally.
169ad35a4c9SJonathan Lemon.It EV_EOF
170ad35a4c9SJonathan LemonFilters may set this flag to indicate filter-specific EOF condition.
171ad35a4c9SJonathan Lemon.It EV_ERROR
172ad35a4c9SJonathan LemonSee
173ad35a4c9SJonathan Lemon.Sx RETURN VALUES
174ad35a4c9SJonathan Lemonbelow.
175ad35a4c9SJonathan Lemon.El
176ad35a4c9SJonathan Lemon.Pp
177ad35a4c9SJonathan LemonThe predefined system filters are listed below.
178ad35a4c9SJonathan LemonArguments may be passed to and from the filter via the
179ad35a4c9SJonathan Lemon.Va fflags
180ad35a4c9SJonathan Lemonand
181ad35a4c9SJonathan Lemon.Va data
182ad35a4c9SJonathan Lemonfields in the kevent structure.
183ad35a4c9SJonathan Lemon.Bl -tag
184ad35a4c9SJonathan Lemon.It EVFILT_READ
185ad35a4c9SJonathan LemonTakes a descriptor as the identifier, and returns whenever
186ad35a4c9SJonathan Lemonthere is data available to read.
187ad35a4c9SJonathan LemonThe behavior of the filter is slightly different depending
188ad35a4c9SJonathan Lemonon the descriptor type.
189ad35a4c9SJonathan Lemon.Bl -tag
190ad35a4c9SJonathan Lemon.It Sockets
191ad35a4c9SJonathan LemonSockets which have previously been passed to
192ad35a4c9SJonathan Lemon.Fn listen
193ad35a4c9SJonathan Lemonreturn when there is an incoming connection pending.
194ad35a4c9SJonathan Lemon.Va data
195ad35a4c9SJonathan Lemoncontains the size of the listen backlog.
196ad35a4c9SJonathan Lemon.Pp
197ad35a4c9SJonathan LemonOther socket descriptors return when there is data to be read,
198ad35a4c9SJonathan Lemonsubject to the SO_RCVLOWAT value of the socket buffer.
199ad35a4c9SJonathan Lemon.Va data
200ad35a4c9SJonathan Lemoncontains the number of bytes in the socket buffer.
201ad35a4c9SJonathan Lemon.Pp
202ad35a4c9SJonathan LemonIf the read direction of the socket has shutdown, then the filter
203ad35a4c9SJonathan Lemonalso sets EV_EOF in
204ad35a4c9SJonathan Lemon.Va flags .
205ad35a4c9SJonathan LemonIt is possible for EOF to be returned (indicating the connection is gone)
206ad35a4c9SJonathan Lemonwhile there is still data pending in the socket buffer.
207ad35a4c9SJonathan Lemon.El
208ad35a4c9SJonathan Lemon.Bl -tag
209ad35a4c9SJonathan Lemon.It Vnodes
210ad35a4c9SJonathan LemonReturns when the file pointer is not at the end of file.
211ad35a4c9SJonathan Lemon.Va data
212ad35a4c9SJonathan Lemoncontains the offset from current position to end of file,
213ad35a4c9SJonathan Lemonand may be negative.
214ad35a4c9SJonathan Lemon.El
215ad35a4c9SJonathan Lemon.Bl -tag
216ad35a4c9SJonathan Lemon.It Fifos, Pipes
217ad35a4c9SJonathan LemonReturns when the there is data to read;
218ad35a4c9SJonathan Lemon.Va data
219ad35a4c9SJonathan Lemoncontains the number of bytes available.
220ad35a4c9SJonathan Lemon.Pp
221ad35a4c9SJonathan LemonWhen the last writer disconnects, the filter will set EV_EOF in
222ad35a4c9SJonathan Lemon.Va flags .
223ad35a4c9SJonathan LemonThis may be cleared by passing in EV_CLEAR, at which point the
224ad35a4c9SJonathan Lemonfilter will resume waiting for data to become available before
225ad35a4c9SJonathan Lemonreturning.
226ad35a4c9SJonathan Lemon.El
227ad35a4c9SJonathan Lemon.El
228ad35a4c9SJonathan Lemon.Bl -tag
229ad35a4c9SJonathan Lemon.It EVFILT_WRITE
230ad35a4c9SJonathan LemonTakes a descriptor as the identifier, and returns whenever
231ad35a4c9SJonathan Lemonit is possible to write to the descriptor.  For sockets, pipes
232ad35a4c9SJonathan Lemonand fifos,
233ad35a4c9SJonathan Lemon.Va data
234ad35a4c9SJonathan Lemonwill contain the amount of space remaining in the write buffer.
235ad35a4c9SJonathan LemonThe filter will set EV_EOF when the reader disconnects, and for
236ad35a4c9SJonathan Lemonthe fifo case, this may be cleared by use of EV_CLEAR.
237ad35a4c9SJonathan LemonNote that this filter is not supported for vnodes.
238ad35a4c9SJonathan Lemon.El
239ad35a4c9SJonathan Lemon.Bl -tag
240ad35a4c9SJonathan Lemon.It EVFILT_AIO
241ad35a4c9SJonathan LemonA kevent structure is initialized, with
242ad35a4c9SJonathan Lemon.Va ident
243ad35a4c9SJonathan Lemoncontaining the descriptor of the kqueue that the event should be
244ad35a4c9SJonathan Lemonattached to.  The address of the kevent structure is then placed in the
245ad35a4c9SJonathan Lemon.Va aio_lio_opcode
246ad35a4c9SJonathan Lemonfield of the AIO request, and the aio_* function is then called.
247ad35a4c9SJonathan LemonThe event will be registered with the specified kqueue, and the
248ad35a4c9SJonathan Lemon.Va ident
249ad35a4c9SJonathan Lemonargument set to the
250ad35a4c9SJonathan Lemon.Fa struct aiocb
251ad35a4c9SJonathan Lemonreturned by the aio_* function.
252ad35a4c9SJonathan LemonThe filter returns under the same conditions as aio_error.
253ad35a4c9SJonathan Lemon.Pp
254ad35a4c9SJonathan LemonNOTE: this interface is unstable and subject to change.
255ad35a4c9SJonathan Lemon.El
256ad35a4c9SJonathan Lemon.Bl -tag
257ad35a4c9SJonathan Lemon.It EVFILT_VNODE
258ad35a4c9SJonathan LemonTakes a file descriptor as the identifier and the events to watch for in
259ad35a4c9SJonathan Lemon.Va fflags ,
260ad35a4c9SJonathan Lemonand returns when one or more of the requested events occurs on the descriptor.
261ad35a4c9SJonathan LemonThe events to monitor are:
262ad35a4c9SJonathan Lemon.Bl -tag -width XXNOTE_RENAME
263ad35a4c9SJonathan Lemon.It NOTE_DELETE
264ad35a4c9SJonathan Lemon.Fn unlink
265ad35a4c9SJonathan Lemonwas called on the file referenced by the descriptor.
266ad35a4c9SJonathan Lemon.It NOTE_WRITE
267ad35a4c9SJonathan LemonA write occurred on the file referenced by the descriptor.
268ad35a4c9SJonathan Lemon.It NOTE_EXTEND
269ad35a4c9SJonathan LemonThe file referenced by the descriptor was extended.
270ad35a4c9SJonathan Lemon.It NOTE_ATTRIB
271ad35a4c9SJonathan LemonThe file referenced by the descriptor had its attributes changed.
272ad35a4c9SJonathan Lemon.It NOTE_LINK
273ad35a4c9SJonathan LemonThe link count on the file changed.
274ad35a4c9SJonathan Lemon.It NOTE_RENAME
275ad35a4c9SJonathan LemonThe file referenced by the descriptor was renamed.
276ad35a4c9SJonathan Lemon.El
277ad35a4c9SJonathan Lemon.Pp
278ad35a4c9SJonathan LemonOn return,
279ad35a4c9SJonathan Lemon.Va fflags
280ad35a4c9SJonathan Lemoncontains the events which triggered the filter.
281ad35a4c9SJonathan Lemon.El
282ad35a4c9SJonathan Lemon.Bl -tag
283ad35a4c9SJonathan Lemon.It EVFILT_PROC
284ad35a4c9SJonathan LemonTakes the process ID to monitor as the identifier and the events to watch for
285ad35a4c9SJonathan Lemonin
286ad35a4c9SJonathan Lemon.Va fflags ,
287ad35a4c9SJonathan Lemonand returns when the process performs one or more of the requested events.
288ad35a4c9SJonathan LemonIf a process can normally see another process, it can attach an event to it.
289ad35a4c9SJonathan LemonThe events to monitor are:
290ad35a4c9SJonathan Lemon.Bl -tag -width XXNOTE_TRACKERR
291ad35a4c9SJonathan Lemon.It NOTE_EXIT
292ad35a4c9SJonathan LemonThe process has exited.
293ad35a4c9SJonathan Lemon.It NOTE_FORK
294ad35a4c9SJonathan LemonThe process has called
295ad35a4c9SJonathan Lemon.Fn fork .
296ad35a4c9SJonathan Lemon.It NOTE_EXEC
297ad35a4c9SJonathan LemonThe process has executed a new process via
298ad35a4c9SJonathan Lemon.Xr execve 2
299ad35a4c9SJonathan Lemonor similar call.
300ad35a4c9SJonathan Lemon.It NOTE_TRACK
301ad35a4c9SJonathan LemonFollow a process across
302ad35a4c9SJonathan Lemon.Fn fork
303ad35a4c9SJonathan Lemoncalls.  The parent process will return with NOTE_TRACK set in the
304ad35a4c9SJonathan Lemon.Va fflags
305ad35a4c9SJonathan Lemonfield, while the child process will return with NOTE_CHILD set in
306ad35a4c9SJonathan Lemon.Va fflags
307ad35a4c9SJonathan Lemonand the parent PID in
308ad35a4c9SJonathan Lemon.Va data .
309ad35a4c9SJonathan Lemon.It NOTE_TRACKERR
310ad35a4c9SJonathan LemonThis flag is returned if the system was unable to attach an event to
311ad35a4c9SJonathan Lemonthe child process, usually due to resource limitations.
312ad35a4c9SJonathan Lemon.El
313ad35a4c9SJonathan Lemon.Pp
314ad35a4c9SJonathan LemonOn return,
315ad35a4c9SJonathan Lemon.Va fflags
316ad35a4c9SJonathan Lemoncontains the events which triggered the filter.
317ad35a4c9SJonathan Lemon.It EVFILT_SIGNAL
318ad35a4c9SJonathan LemonTakes the signal number to monitor as the identifier and returns
319ad35a4c9SJonathan Lemonwhen the given signal is delivered to the process.
320ad35a4c9SJonathan LemonThis coexists with the
321ad35a4c9SJonathan Lemon.Fn signal
322ad35a4c9SJonathan Lemonand
323ad35a4c9SJonathan Lemon.Fn sigaction
324ad35a4c9SJonathan Lemonfacilities, and has a lower precedence.  The filter will record
325ad35a4c9SJonathan Lemonall attempts to deliver a signal to a process, even if the signal has
326ad35a4c9SJonathan Lemonbeen marked as SIG_IGN.  Event notification happens after normal
327ad35a4c9SJonathan Lemonsignal delivery processing.
328ad35a4c9SJonathan Lemon.Va data
329ad35a4c9SJonathan Lemonreturns the number of times the signal has occurred since the last call to
330ad35a4c9SJonathan Lemon.Fn kqueue .
331ad35a4c9SJonathan LemonThis filter automatically sets the EV_CLEAR flag internally.
332ad35a4c9SJonathan Lemon.El
333ad35a4c9SJonathan Lemon.Sh RETURN VALUES
334ad35a4c9SJonathan Lemon.Fn kevent
335ad35a4c9SJonathan Lemonreturns the number of events placed in the
336ad35a4c9SJonathan Lemon.Ar eventlist ,
337ad35a4c9SJonathan Lemonup to the value given by
338ad35a4c9SJonathan Lemon.Ar nevents .
339ad35a4c9SJonathan LemonIf an error occurs while processing an element of the
340ad35a4c9SJonathan Lemon.Ar changelist
341ad35a4c9SJonathan Lemonand there is enough room in the
342ad35a4c9SJonathan Lemon.Ar eventlist ,
343ad35a4c9SJonathan Lemonthen the event will be placed in the
344ad35a4c9SJonathan Lemon.Ar eventlist
345ad35a4c9SJonathan Lemonwith
346ad35a4c9SJonathan Lemon.Dv EV_ERROR
347ad35a4c9SJonathan Lemonset in
348ad35a4c9SJonathan Lemon.Va flags
349ad35a4c9SJonathan Lemonand the system error in
350ad35a4c9SJonathan Lemon.Va data .
351ad35a4c9SJonathan LemonOtherwise,
352ad35a4c9SJonathan Lemon.Dv -1
353ad35a4c9SJonathan Lemonwill be returned, and
354ad35a4c9SJonathan Lemon.Dv errno
355ad35a4c9SJonathan Lemonwill be set to indicate the error condition.
356ad35a4c9SJonathan LemonIf the time limit expires, then
357ad35a4c9SJonathan Lemon.Fn kevent
358ad35a4c9SJonathan Lemonreturns 0.
359ad35a4c9SJonathan Lemon.Sh ERRORS
360ad35a4c9SJonathan LemonThe
361ad35a4c9SJonathan Lemon.Fn kevent
362ad35a4c9SJonathan Lemonfunction fails if:
363ad35a4c9SJonathan Lemon.Bl -tag -width Er
364ad35a4c9SJonathan Lemon.It Bq Er EACCESS
365ad35a4c9SJonathan LemonThe process does not have permission to register a filter.
366ad35a4c9SJonathan Lemon.It Bq Er EFAULT
367ad35a4c9SJonathan LemonThere was an error reading or writing the
368ad35a4c9SJonathan Lemon.Va kevent
369ad35a4c9SJonathan Lemonstructure.
370ad35a4c9SJonathan Lemon.It Bq Er EBADF
371ad35a4c9SJonathan LemonThe specified descriptor is invalid.
372ad35a4c9SJonathan Lemon.It Bq Er EINTR
373ad35a4c9SJonathan LemonA signal was delivered before the timeout expired and before any
374ad35a4c9SJonathan Lemonevents were placed on the kqueue for return.
375ad35a4c9SJonathan Lemon.It Bq Er EINVAL
376ad35a4c9SJonathan LemonThe specified time limit or filter is invalid.
377ad35a4c9SJonathan Lemon.It Bq Er ENOMEM
378ad35a4c9SJonathan LemonNo memory was available to register the event.
379ad35a4c9SJonathan Lemon.It Bq Er ESRCH
380ad35a4c9SJonathan LemonThe specified process to attach to does not exist.
381ad35a4c9SJonathan Lemon.El
382ad35a4c9SJonathan Lemon.Sh SEE ALSO
383ad35a4c9SJonathan Lemon.Xr aio_error 2 ,
384ad35a4c9SJonathan Lemon.Xr aio_read 2 ,
385ad35a4c9SJonathan Lemon.Xr aio_return 2 ,
386ad35a4c9SJonathan Lemon.Xr poll 2 ,
387ad35a4c9SJonathan Lemon.Xr read 2 ,
388ad35a4c9SJonathan Lemon.Xr select 2 ,
389ad35a4c9SJonathan Lemon.Xr signal 3 ,
390ad35a4c9SJonathan Lemon.Xr sigaction 2 ,
391*4451bb5dSJonathan Lemon.Xr write 2
392ad35a4c9SJonathan Lemon.Sh HISTORY
393ad35a4c9SJonathan LemonThe
394ad35a4c9SJonathan Lemon.Fn kqueue
395ad35a4c9SJonathan Lemonand
396ad35a4c9SJonathan Lemon.Fn kevent
397ad35a4c9SJonathan Lemonfunctions first appeared in
398ad35a4c9SJonathan Lemon.Fx 5.0 .
399*4451bb5dSJonathan Lemon.Sh AUTHORS
400ad35a4c9SJonathan LemonThe
401ad35a4c9SJonathan Lemon.Fn kqueue
402ad35a4c9SJonathan Lemonsystem and this manual page were written by
403*4451bb5dSJonathan Lemon.An Jonathan Lemon Aq [email protected] .
404