xref: /freebsd-13.1/lib/libc/sys/kqueue.2 (revision 17c847c1)
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.\"
27b11ef6e9SSergey Kandaurov.Dd April 18, 2017
28ad35a4c9SJonathan Lemon.Dt KQUEUE 2
29ad35a4c9SJonathan Lemon.Os
30ad35a4c9SJonathan Lemon.Sh NAME
314451bb5dSJonathan Lemon.Nm kqueue ,
324451bb5dSJonathan Lemon.Nm kevent
33ad35a4c9SJonathan Lemon.Nd kernel event notification mechanism
344451bb5dSJonathan Lemon.Sh LIBRARY
354451bb5dSJonathan Lemon.Lb libc
36ad35a4c9SJonathan Lemon.Sh SYNOPSIS
3732eef9aeSRuslan Ermilov.In sys/event.h
38ad35a4c9SJonathan Lemon.Ft int
39ad35a4c9SJonathan Lemon.Fn kqueue "void"
40ad35a4c9SJonathan Lemon.Ft int
41a8e65b91SJonathan Lemon.Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout"
42b072e86dSKonstantin Belousov.Fn EV_SET "kev" ident filter flags fflags data udata
43ad35a4c9SJonathan Lemon.Sh DESCRIPTION
442faeeff4SRuslan ErmilovThe
45ad35a4c9SJonathan Lemon.Fn kqueue
462faeeff4SRuslan Ermilovsystem call
47ad35a4c9SJonathan Lemonprovides a generic method of notifying the user when an event
48ad35a4c9SJonathan Lemonhappens or a condition holds, based on the results of small
49ad35a4c9SJonathan Lemonpieces of kernel code termed filters.
503c63f48cSSheldon HearnA kevent is identified by the (ident, filter) pair; there may only
51ad35a4c9SJonathan Lemonbe one unique kevent per kqueue.
524451bb5dSJonathan Lemon.Pp
53ad35a4c9SJonathan LemonThe filter is executed upon the initial registration of a kevent
543c63f48cSSheldon Hearnin order to detect whether a preexisting condition is present, and is also
55ad35a4c9SJonathan Lemonexecuted whenever an event is passed to the filter for evaluation.
56ad35a4c9SJonathan LemonIf the filter determines that the condition should be reported,
57ad35a4c9SJonathan Lemonthen the kevent is placed on the kqueue for the user to retrieve.
584451bb5dSJonathan Lemon.Pp
59ad35a4c9SJonathan LemonThe filter is also run when the user attempts to retrieve the kevent
603c63f48cSSheldon Hearnfrom the kqueue.
613c63f48cSSheldon HearnIf the filter indicates that the condition that triggered
62ad35a4c9SJonathan Lemonthe event no longer holds, the kevent is removed from the kqueue and
63ad35a4c9SJonathan Lemonis not returned.
644451bb5dSJonathan Lemon.Pp
65ad35a4c9SJonathan LemonMultiple events which trigger the filter do not result in multiple
66ad35a4c9SJonathan Lemonkevents being placed on the kqueue; instead, the filter will aggregate
67ad35a4c9SJonathan Lemonthe events into a single struct kevent.
68ad35a4c9SJonathan LemonCalling
69ad35a4c9SJonathan Lemon.Fn close
70ad35a4c9SJonathan Lemonon a file descriptor will remove any kevents that reference the descriptor.
71ad35a4c9SJonathan Lemon.Pp
722faeeff4SRuslan ErmilovThe
73ad35a4c9SJonathan Lemon.Fn kqueue
742faeeff4SRuslan Ermilovsystem call
75ad35a4c9SJonathan Lemoncreates a new kernel event queue and returns a descriptor.
76af7b56f4SJohn-Mark GurneyThe queue is not inherited by a child created with
77af7b56f4SJohn-Mark Gurney.Xr fork 2 .
783c63f48cSSheldon HearnHowever, if
793c63f48cSSheldon Hearn.Xr rfork 2
80ee85cf8bSJonathan Lemonis called without the
813c63f48cSSheldon Hearn.Dv RFFDG
82ee85cf8bSJonathan Lemonflag, then the descriptor table is shared,
83af7b56f4SJohn-Mark Gurneywhich will allow sharing of the kqueue between two processes.
84ad35a4c9SJonathan Lemon.Pp
852faeeff4SRuslan ErmilovThe
86ad35a4c9SJonathan Lemon.Fn kevent
872faeeff4SRuslan Ermilovsystem call
88ad35a4c9SJonathan Lemonis used to register events with the queue, and return any pending
89ad35a4c9SJonathan Lemonevents to the user.
902efeeba5SRuslan ErmilovThe
91ad35a4c9SJonathan Lemon.Fa changelist
922efeeba5SRuslan Ermilovargument
93a8e65b91SJonathan Lemonis a pointer to an array of
94ad35a4c9SJonathan Lemon.Va kevent
95ad35a4c9SJonathan Lemonstructures, as defined in
96fe08efe6SRuslan Ermilov.In sys/event.h .
97ad35a4c9SJonathan LemonAll changes contained in the
98ad35a4c9SJonathan Lemon.Fa changelist
99ad35a4c9SJonathan Lemonare applied before any pending events are read from the queue.
1002efeeba5SRuslan ErmilovThe
101ad35a4c9SJonathan Lemon.Fa nchanges
1022efeeba5SRuslan Ermilovargument
103ad35a4c9SJonathan Lemongives the size of
104ad35a4c9SJonathan Lemon.Fa changelist .
1052efeeba5SRuslan ErmilovThe
106ad35a4c9SJonathan Lemon.Fa eventlist
1072efeeba5SRuslan Ermilovargument
108ad35a4c9SJonathan Lemonis a pointer to an array of kevent structures.
1092efeeba5SRuslan ErmilovThe
110ad35a4c9SJonathan Lemon.Fa nevents
1112efeeba5SRuslan Ermilovargument
112ad35a4c9SJonathan Lemondetermines the size of
113ad35a4c9SJonathan Lemon.Fa eventlist .
114634862b3SJohn-Mark GurneyWhen
115634862b3SJohn-Mark Gurney.Fa nevents
116634862b3SJohn-Mark Gurneyis zero,
117634862b3SJohn-Mark Gurney.Fn kevent
118634862b3SJohn-Mark Gurneywill return immediately even if there is a
119634862b3SJohn-Mark Gurney.Fa timeout
120634862b3SJohn-Mark Gurneyspecified unlike
121634862b3SJohn-Mark Gurney.Xr select 2 .
122ad35a4c9SJonathan LemonIf
123ad35a4c9SJonathan Lemon.Fa timeout
124ad35a4c9SJonathan Lemonis a non-NULL pointer, it specifies a maximum interval to wait
1251a0a9345SRuslan Ermilovfor an event, which will be interpreted as a struct timespec.
1261a0a9345SRuslan ErmilovIf
127ad35a4c9SJonathan Lemon.Fa timeout
128ad35a4c9SJonathan Lemonis a NULL pointer,
129ad35a4c9SJonathan Lemon.Fn kevent
1301a0a9345SRuslan Ermilovwaits indefinitely.
1311a0a9345SRuslan ErmilovTo effect a poll, the
132ad35a4c9SJonathan Lemon.Fa timeout
133ad35a4c9SJonathan Lemonargument should be non-NULL, pointing to a zero-valued
134ad35a4c9SJonathan Lemon.Va timespec
1351a0a9345SRuslan Ermilovstructure.
1361a0a9345SRuslan ErmilovThe same array may be used for the
137ee85cf8bSJonathan Lemon.Fa changelist
138ee85cf8bSJonathan Lemonand
139ee85cf8bSJonathan Lemon.Fa eventlist .
140ad35a4c9SJonathan Lemon.Pp
1412faeeff4SRuslan ErmilovThe
1425d1c9c56SJonathan Lemon.Fn EV_SET
1432faeeff4SRuslan Ermilovmacro is provided for ease of initializing a
1445d1c9c56SJonathan Lemonkevent structure.
1455d1c9c56SJonathan Lemon.Pp
146ad35a4c9SJonathan LemonThe
147ad35a4c9SJonathan Lemon.Va kevent
148ad35a4c9SJonathan Lemonstructure is defined as:
149ad35a4c9SJonathan Lemon.Bd -literal
150ad35a4c9SJonathan Lemonstruct kevent {
151ad35a4c9SJonathan Lemon	uintptr_t ident;	/* identifier for this event */
152ad35a4c9SJonathan Lemon	short	  filter;	/* filter for event */
153ad35a4c9SJonathan Lemon	u_short	  flags;	/* action flags for kqueue */
154ad35a4c9SJonathan Lemon	u_int	  fflags;	/* filter flag value */
155ad35a4c9SJonathan Lemon	intptr_t  data;		/* filter data value */
156ad35a4c9SJonathan Lemon	void	  *udata;	/* opaque user data identifier */
157ad35a4c9SJonathan Lemon};
158ad35a4c9SJonathan Lemon.Ed
159ad35a4c9SJonathan Lemon.Pp
160ad35a4c9SJonathan LemonThe fields of
161ad35a4c9SJonathan Lemon.Fa struct kevent
162ad35a4c9SJonathan Lemonare:
16319eaed53SKonstantin Belousov.Bl -tag -width "Fa filter"
16419eaed53SKonstantin Belousov.It Fa ident
165ad35a4c9SJonathan LemonValue used to identify this event.
166ad35a4c9SJonathan LemonThe exact interpretation is determined by the attached filter,
167ad35a4c9SJonathan Lemonbut often is a file descriptor.
16819eaed53SKonstantin Belousov.It Fa filter
1691a0a9345SRuslan ErmilovIdentifies the kernel filter used to process this event.
1701a0a9345SRuslan ErmilovThe pre-defined
171ad35a4c9SJonathan Lemonsystem filters are described below.
17219eaed53SKonstantin Belousov.It Fa flags
173ad35a4c9SJonathan LemonActions to perform on the event.
17419eaed53SKonstantin Belousov.It Fa fflags
175ad35a4c9SJonathan LemonFilter-specific flags.
17619eaed53SKonstantin Belousov.It Fa data
177ad35a4c9SJonathan LemonFilter-specific data value.
17819eaed53SKonstantin Belousov.It Fa udata
179ad35a4c9SJonathan LemonOpaque user-defined value passed through the kernel unchanged.
180ad35a4c9SJonathan Lemon.El
181ad35a4c9SJonathan Lemon.Pp
182ad35a4c9SJonathan LemonThe
183ad35a4c9SJonathan Lemon.Va flags
184ad35a4c9SJonathan Lemonfield can contain the following values:
18519eaed53SKonstantin Belousov.Bl -tag -width EV_DISPATCH
18619eaed53SKonstantin Belousov.It Dv EV_ADD
1871a0a9345SRuslan ErmilovAdds the event to the kqueue.
1881a0a9345SRuslan ErmilovRe-adding an existing event
189ad35a4c9SJonathan Lemonwill modify the parameters of the original event, and not result
1901a0a9345SRuslan Ermilovin a duplicate entry.
1911a0a9345SRuslan ErmilovAdding an event automatically enables it,
192ad35a4c9SJonathan Lemonunless overridden by the EV_DISABLE flag.
19319eaed53SKonstantin Belousov.It Dv EV_ENABLE
194ad35a4c9SJonathan LemonPermit
195ad35a4c9SJonathan Lemon.Fn kevent
196ad35a4c9SJonathan Lemonto return the event if it is triggered.
19719eaed53SKonstantin Belousov.It Dv EV_DISABLE
198ad35a4c9SJonathan LemonDisable the event so
199ad35a4c9SJonathan Lemon.Fn kevent
2001a0a9345SRuslan Ermilovwill not return it.
2011a0a9345SRuslan ErmilovThe filter itself is not disabled.
20219eaed53SKonstantin Belousov.It Dv EV_DISPATCH
2031a921c41SStacey SonDisable the event source immediately after delivery of an event.
2041a921c41SStacey SonSee
2051a921c41SStacey Son.Dv EV_DISABLE
2061a921c41SStacey Sonabove.
20719eaed53SKonstantin Belousov.It Dv EV_DELETE
2081a0a9345SRuslan ErmilovRemoves the event from the kqueue.
2091a0a9345SRuslan ErmilovEvents which are attached to
210ad35a4c9SJonathan Lemonfile descriptors are automatically deleted on the last close of
211ad35a4c9SJonathan Lemonthe descriptor.
21219eaed53SKonstantin Belousov.It Dv EV_RECEIPT
213fdc1a113SStacey SonThis flag is useful for making bulk changes to a kqueue without draining
214fdc1a113SStacey Sonany pending events.
215fdc1a113SStacey SonWhen passed as input, it forces
216fdc1a113SStacey Son.Dv EV_ERROR
217fdc1a113SStacey Sonto always be returned.
218fdc1a113SStacey SonWhen a filter is successfully added the
219fdc1a113SStacey Son.Va data
220fdc1a113SStacey Sonfield will be zero.
22119eaed53SKonstantin Belousov.It Dv EV_ONESHOT
222ad35a4c9SJonathan LemonCauses the event to return only the first occurrence of the filter
2231a0a9345SRuslan Ermilovbeing triggered.
2241a0a9345SRuslan ErmilovAfter the user retrieves the event from the kqueue,
225ad35a4c9SJonathan Lemonit is deleted.
22619eaed53SKonstantin Belousov.It Dv EV_CLEAR
227ad35a4c9SJonathan LemonAfter the event is retrieved by the user, its state is reset.
228ad35a4c9SJonathan LemonThis is useful for filters which report state transitions
2291a0a9345SRuslan Ermilovinstead of the current state.
2301a0a9345SRuslan ErmilovNote that some filters may automatically
231ad35a4c9SJonathan Lemonset this flag internally.
23219eaed53SKonstantin Belousov.It Dv EV_EOF
233ad35a4c9SJonathan LemonFilters may set this flag to indicate filter-specific EOF condition.
23419eaed53SKonstantin Belousov.It Dv EV_ERROR
235ad35a4c9SJonathan LemonSee
236ad35a4c9SJonathan Lemon.Sx RETURN VALUES
237ad35a4c9SJonathan Lemonbelow.
238ad35a4c9SJonathan Lemon.El
239ad35a4c9SJonathan Lemon.Pp
240ad35a4c9SJonathan LemonThe predefined system filters are listed below.
241ad35a4c9SJonathan LemonArguments may be passed to and from the filter via the
242ad35a4c9SJonathan Lemon.Va fflags
243ad35a4c9SJonathan Lemonand
244ad35a4c9SJonathan Lemon.Va data
245ad35a4c9SJonathan Lemonfields in the kevent structure.
24619eaed53SKonstantin Belousov.Bl -tag -width "Dv EVFILT_PROCDESC"
24719eaed53SKonstantin Belousov.It Dv EVFILT_READ
248ad35a4c9SJonathan LemonTakes a descriptor as the identifier, and returns whenever
249ad35a4c9SJonathan Lemonthere is data available to read.
250ad35a4c9SJonathan LemonThe behavior of the filter is slightly different depending
251ad35a4c9SJonathan Lemonon the descriptor type.
25242635956SRuslan Ermilov.Bl -tag -width 2n
253ad35a4c9SJonathan Lemon.It Sockets
254ad35a4c9SJonathan LemonSockets which have previously been passed to
255ad35a4c9SJonathan Lemon.Fn listen
256ad35a4c9SJonathan Lemonreturn when there is an incoming connection pending.
257ad35a4c9SJonathan Lemon.Va data
258ad35a4c9SJonathan Lemoncontains the size of the listen backlog.
259ad35a4c9SJonathan Lemon.Pp
260ad35a4c9SJonathan LemonOther socket descriptors return when there is data to be read,
2615d1c9c56SJonathan Lemonsubject to the
2625d1c9c56SJonathan Lemon.Dv SO_RCVLOWAT
2635d1c9c56SJonathan Lemonvalue of the socket buffer.
2645d1c9c56SJonathan LemonThis may be overridden with a per-filter low water mark at the
2655d1c9c56SJonathan Lemontime the filter is added by setting the
26619eaed53SKonstantin Belousov.Dv NOTE_LOWAT
2675d1c9c56SJonathan Lemonflag in
2685d1c9c56SJonathan Lemon.Va fflags ,
2695d1c9c56SJonathan Lemonand specifying the new low water mark in
2705d1c9c56SJonathan Lemon.Va data .
2715d1c9c56SJonathan LemonOn return,
272ad35a4c9SJonathan Lemon.Va data
273e0f640e8SKelly Yanceycontains the number of bytes of protocol data available to read.
274ad35a4c9SJonathan Lemon.Pp
275ad35a4c9SJonathan LemonIf the read direction of the socket has shutdown, then the filter
27619eaed53SKonstantin Belousovalso sets
27719eaed53SKonstantin Belousov.Dv EV_EOF
27819eaed53SKonstantin Belousovin
2795d1c9c56SJonathan Lemon.Va flags ,
2805d1c9c56SJonathan Lemonand returns the socket error (if any) in
2815d1c9c56SJonathan Lemon.Va fflags .
282ad35a4c9SJonathan LemonIt is possible for EOF to be returned (indicating the connection is gone)
283ad35a4c9SJonathan Lemonwhile there is still data pending in the socket buffer.
284ad35a4c9SJonathan Lemon.It Vnodes
285ad35a4c9SJonathan LemonReturns when the file pointer is not at the end of file.
286ad35a4c9SJonathan Lemon.Va data
287ad35a4c9SJonathan Lemoncontains the offset from current position to end of file,
288ad35a4c9SJonathan Lemonand may be negative.
2892433a4ebSEd Schouten.Pp
2902433a4ebSEd SchoutenThis behavior is different from
2912433a4ebSEd Schouten.Xr poll 2 ,
2922433a4ebSEd Schoutenwhere read events are triggered for regular files unconditionally.
2932433a4ebSEd SchoutenThis event can be triggered unconditionally by setting the
2942433a4ebSEd Schouten.Dv NOTE_FILE_POLL
2952433a4ebSEd Schoutenflag in
2962433a4ebSEd Schouten.Va fflags .
29742635956SRuslan Ermilov.It "Fifos, Pipes"
298ad35a4c9SJonathan LemonReturns when the there is data to read;
299ad35a4c9SJonathan Lemon.Va data
300ad35a4c9SJonathan Lemoncontains the number of bytes available.
301ad35a4c9SJonathan Lemon.Pp
30219eaed53SKonstantin BelousovWhen the last writer disconnects, the filter will set
30319eaed53SKonstantin Belousov.Dv EV_EOF
30419eaed53SKonstantin Belousovin
305ad35a4c9SJonathan Lemon.Va flags .
30619eaed53SKonstantin BelousovThis may be cleared by passing in
30719eaed53SKonstantin Belousov.Dv EV_CLEAR ,
30819eaed53SKonstantin Belousovat which point the
309ad35a4c9SJonathan Lemonfilter will resume waiting for data to become available before
310ad35a4c9SJonathan Lemonreturning.
31195aab9ccSJohn-Mark Gurney.It "BPF devices"
31295aab9ccSJohn-Mark GurneyReturns when the BPF buffer is full, the BPF timeout has expired, or
31395aab9ccSJohn-Mark Gurneywhen the BPF has
31495aab9ccSJohn-Mark Gurney.Dq immediate mode
31595aab9ccSJohn-Mark Gurneyenabled and there is any data to read;
31695aab9ccSJohn-Mark Gurney.Va data
31795aab9ccSJohn-Mark Gurneycontains the number of bytes available.
318ad35a4c9SJonathan Lemon.El
31919eaed53SKonstantin Belousov.It Dv EVFILT_WRITE
320ad35a4c9SJonathan LemonTakes a descriptor as the identifier, and returns whenever
3211a0a9345SRuslan Ermilovit is possible to write to the descriptor.
3221a0a9345SRuslan ErmilovFor sockets, pipes
323ad35a4c9SJonathan Lemonand fifos,
324ad35a4c9SJonathan Lemon.Va data
325ad35a4c9SJonathan Lemonwill contain the amount of space remaining in the write buffer.
326ad35a4c9SJonathan LemonThe filter will set EV_EOF when the reader disconnects, and for
32719eaed53SKonstantin Belousovthe fifo case, this may be cleared by use of
32819eaed53SKonstantin Belousov.Dv EV_CLEAR .
32995aab9ccSJohn-Mark GurneyNote that this filter is not supported for vnodes or BPF devices.
3305d1c9c56SJonathan Lemon.Pp
3315d1c9c56SJonathan LemonFor sockets, the low water mark and socket error handling is
33219eaed53SKonstantin Belousovidentical to the
33319eaed53SKonstantin Belousov.Dv EVFILT_READ
33419eaed53SKonstantin Belousovcase.
335b11ef6e9SSergey Kandaurov.It Dv EVFILT_EMPTY
336b11ef6e9SSergey KandaurovTakes a descriptor as the identifier, and returns whenever
337b11ef6e9SSergey Kandaurovthere is no remaining data in the write buffer.
33819eaed53SKonstantin Belousov.It Dv EVFILT_AIO
3395d1c9c56SJonathan LemonThe sigevent portion of the AIO request is filled in, with
3405d1c9c56SJonathan Lemon.Va sigev_notify_kqueue
3415d1c9c56SJonathan Lemoncontaining the descriptor of the kqueue that the event should
3425d1c9c56SJonathan Lemonbe attached to,
34303a67b59SDavid Xu.Va sigev_notify_kevent_flags
34419eaed53SKonstantin Belousovcontaining the kevent flags which should be
34519eaed53SKonstantin Belousov.Dv EV_ONESHOT ,
34619eaed53SKonstantin Belousov.Dv EV_CLEAR
34719eaed53SKonstantin Belousovor
34819eaed53SKonstantin Belousov.Dv EV_DISPATCH ,
3495d1c9c56SJonathan Lemon.Va sigev_value
3505d1c9c56SJonathan Lemoncontaining the udata value, and
3515d1c9c56SJonathan Lemon.Va sigev_notify
35219eaed53SKonstantin Belousovset to
35319eaed53SKonstantin Belousov.Dv SIGEV_KEVENT .
3542faeeff4SRuslan ErmilovWhen the
3552faeeff4SRuslan Ermilov.Fn aio_*
3562faeeff4SRuslan Ermilovsystem call is made, the event will be registered
3575d1c9c56SJonathan Lemonwith the specified kqueue, and the
358ad35a4c9SJonathan Lemon.Va ident
359ad35a4c9SJonathan Lemonargument set to the
360ad35a4c9SJonathan Lemon.Fa struct aiocb
3612faeeff4SRuslan Ermilovreturned by the
3622faeeff4SRuslan Ermilov.Fn aio_*
3632faeeff4SRuslan Ermilovsystem call.
36419eaed53SKonstantin BelousovThe filter returns under the same conditions as
36519eaed53SKonstantin Belousov.Fn aio_error .
36619eaed53SKonstantin Belousov.It Dv EVFILT_VNODE
367ad35a4c9SJonathan LemonTakes a file descriptor as the identifier and the events to watch for in
368ad35a4c9SJonathan Lemon.Va fflags ,
369ad35a4c9SJonathan Lemonand returns when one or more of the requested events occurs on the descriptor.
370ad35a4c9SJonathan LemonThe events to monitor are:
371c89e1b87SKonstantin Belousov.Bl -tag -width "Dv NOTE_CLOSE_WRITE"
372c89e1b87SKonstantin Belousov.It Dv NOTE_ATTRIB
373c89e1b87SKonstantin BelousovThe file referenced by the descriptor had its attributes changed.
374c89e1b87SKonstantin Belousov.It Dv NOTE_CLOSE
375c89e1b87SKonstantin BelousovA file descriptor referencing the monitored file, was closed.
3766e745eedSKonstantin BelousovThe closed file descriptor did not have write access.
377c89e1b87SKonstantin Belousov.It Dv NOTE_CLOSE_WRITE
378c89e1b87SKonstantin BelousovA file descriptor referencing the monitored file, was closed.
3793617efe5SBryan DreweryThe closed file descriptor had write access.
380c89e1b87SKonstantin Belousov.Pp
381c89e1b87SKonstantin BelousovThis note, as well as
382c89e1b87SKonstantin Belousov.Dv NOTE_CLOSE ,
383c89e1b87SKonstantin Belousovare not activated when files are closed forcibly by
384c89e1b87SKonstantin Belousov.Xr unmount 2 or
385c89e1b87SKonstantin Belousov.Xr revoke 2 .
386c89e1b87SKonstantin BelousovInstead,
387c89e1b87SKonstantin Belousov.Dv NOTE_REVOKE
388c89e1b87SKonstantin Belousovis sent for such events.
38919eaed53SKonstantin Belousov.It Dv NOTE_DELETE
3902faeeff4SRuslan ErmilovThe
391ad35a4c9SJonathan Lemon.Fn unlink
392c89e1b87SKonstantin Belousovsystem call was called on the file referenced by the descriptor.
39319eaed53SKonstantin Belousov.It Dv NOTE_EXTEND
394f7b71c8aSKonstantin BelousovFor regular file, the file referenced by the descriptor was extended.
395f7b71c8aSKonstantin Belousov.Pp
396f7b71c8aSKonstantin BelousovFor directory, reports that a directory entry was added or removed,
397f7b71c8aSKonstantin Belousovas the result of rename operation.
398f7b71c8aSKonstantin BelousovThe
399f7b71c8aSKonstantin Belousov.Dv NOTE_EXTEND
400f7b71c8aSKonstantin Belousovevent is not reported when a name is changed inside the directory.
40119eaed53SKonstantin Belousov.It Dv NOTE_LINK
402ad35a4c9SJonathan LemonThe link count on the file changed.
403ba55e112SKonstantin BelousovIn particular, the
404ba55e112SKonstantin Belousov.Dv NOTE_LINK
405ba55e112SKonstantin Belousovevent is reported if a subdirectory was created or deleted inside
406ba55e112SKonstantin Belousovthe directory referenced by the descriptor.
407c89e1b87SKonstantin Belousov.It Dv NOTE_OPEN
408c89e1b87SKonstantin BelousovThe file referenced by the descriptor was opened.
409c89e1b87SKonstantin Belousov.It Dv NOTE_READ
410c89e1b87SKonstantin BelousovA read occurred on the file referenced by the descriptor.
41119eaed53SKonstantin Belousov.It Dv NOTE_RENAME
412ad35a4c9SJonathan LemonThe file referenced by the descriptor was renamed.
41319eaed53SKonstantin Belousov.It Dv NOTE_REVOKE
4145d1c9c56SJonathan LemonAccess to the file was revoked via
4155d1c9c56SJonathan Lemon.Xr revoke 2
4163c6dd63bSMike Pritchardor the underlying file system was unmounted.
417c89e1b87SKonstantin Belousov.It Dv NOTE_WRITE
418c89e1b87SKonstantin BelousovA write occurred on the file referenced by the descriptor.
419ad35a4c9SJonathan Lemon.El
420ad35a4c9SJonathan Lemon.Pp
421ad35a4c9SJonathan LemonOn return,
422ad35a4c9SJonathan Lemon.Va fflags
423ad35a4c9SJonathan Lemoncontains the events which triggered the filter.
42419eaed53SKonstantin Belousov.It Dv EVFILT_PROC
425ad35a4c9SJonathan LemonTakes the process ID to monitor as the identifier and the events to watch for
426ad35a4c9SJonathan Lemonin
427ad35a4c9SJonathan Lemon.Va fflags ,
428ad35a4c9SJonathan Lemonand returns when the process performs one or more of the requested events.
429ad35a4c9SJonathan LemonIf a process can normally see another process, it can attach an event to it.
430ad35a4c9SJonathan LemonThe events to monitor are:
43119eaed53SKonstantin Belousov.Bl -tag -width "Dv NOTE_TRACKERR"
43219eaed53SKonstantin Belousov.It Dv NOTE_EXIT
433ad35a4c9SJonathan LemonThe process has exited.
4348cc7b0f9SJohn BaldwinThe exit status will be stored in
4358cc7b0f9SJohn Baldwin.Va data .
43619eaed53SKonstantin Belousov.It Dv NOTE_FORK
437ad35a4c9SJonathan LemonThe process has called
438ad35a4c9SJonathan Lemon.Fn fork .
43919eaed53SKonstantin Belousov.It Dv NOTE_EXEC
440ad35a4c9SJonathan LemonThe process has executed a new process via
441ad35a4c9SJonathan Lemon.Xr execve 2
442513bfc4fSJohn Baldwinor a similar call.
44319eaed53SKonstantin Belousov.It Dv NOTE_TRACK
444ad35a4c9SJonathan LemonFollow a process across
445ad35a4c9SJonathan Lemon.Fn fork
4461a0a9345SRuslan Ermilovcalls.
447513bfc4fSJohn BaldwinThe parent process registers a new kevent to monitor the child process
448513bfc4fSJohn Baldwinusing the same
449ad35a4c9SJonathan Lemon.Va fflags
450513bfc4fSJohn Baldwinas the original event.
45119eaed53SKonstantin BelousovThe child process will signal an event with
45219eaed53SKonstantin Belousov.Dv NOTE_CHILD
45319eaed53SKonstantin Belousovset in
454ad35a4c9SJonathan Lemon.Va fflags
455ad35a4c9SJonathan Lemonand the parent PID in
456ad35a4c9SJonathan Lemon.Va data .
457513bfc4fSJohn Baldwin.Pp
458513bfc4fSJohn BaldwinIf the parent process fails to register a new kevent
459513bfc4fSJohn Baldwin.Pq usually due to resource limitations ,
46019eaed53SKonstantin Belousovit will signal an event with
46119eaed53SKonstantin Belousov.Dv NOTE_TRACKERR
46219eaed53SKonstantin Belousovset in
463513bfc4fSJohn Baldwin.Va fflags ,
46419eaed53SKonstantin Belousovand the child process will not signal a
46519eaed53SKonstantin Belousov.Dv NOTE_CHILD
46619eaed53SKonstantin Belousovevent.
467ad35a4c9SJonathan Lemon.El
468ad35a4c9SJonathan Lemon.Pp
469ad35a4c9SJonathan LemonOn return,
470ad35a4c9SJonathan Lemon.Va fflags
471ad35a4c9SJonathan Lemoncontains the events which triggered the filter.
47219eaed53SKonstantin Belousov.It Dv EVFILT_PROCDESC
47338219d6aSEd SchoutenTakes the process descriptor created by
47438219d6aSEd Schouten.Xr pdfork 2
47538219d6aSEd Schoutento monitor as the identifier and the events to watch for in
47638219d6aSEd Schouten.Va fflags ,
47738219d6aSEd Schoutenand returns when the associated process performs one or more of the
47838219d6aSEd Schoutenrequested events.
47938219d6aSEd SchoutenThe events to monitor are:
48019eaed53SKonstantin Belousov.Bl -tag -width "Dv NOTE_EXIT"
48119eaed53SKonstantin Belousov.It Dv NOTE_EXIT
48238219d6aSEd SchoutenThe process has exited.
48338219d6aSEd SchoutenThe exit status will be stored in
48438219d6aSEd Schouten.Va data .
48538219d6aSEd Schouten.El
48638219d6aSEd Schouten.Pp
48738219d6aSEd SchoutenOn return,
48838219d6aSEd Schouten.Va fflags
48938219d6aSEd Schoutencontains the events which triggered the filter.
49019eaed53SKonstantin Belousov.It Dv EVFILT_SIGNAL
491ad35a4c9SJonathan LemonTakes the signal number to monitor as the identifier and returns
492ad35a4c9SJonathan Lemonwhen the given signal is delivered to the process.
493ad35a4c9SJonathan LemonThis coexists with the
494ad35a4c9SJonathan Lemon.Fn signal
495ad35a4c9SJonathan Lemonand
496ad35a4c9SJonathan Lemon.Fn sigaction
4971a0a9345SRuslan Ermilovfacilities, and has a lower precedence.
4981a0a9345SRuslan ErmilovThe filter will record
499ad35a4c9SJonathan Lemonall attempts to deliver a signal to a process, even if the signal has
50019eaed53SKonstantin Belousovbeen marked as
50119eaed53SKonstantin Belousov.Dv SIG_IGN ,
50219eaed53SKonstantin Belousovexcept for the
503ffce2a5bSPawel Jakub Dawidek.Dv SIGCHLD
504ffce2a5bSPawel Jakub Dawideksignal, which, if ignored, won't be recorded by the filter.
5051a0a9345SRuslan ErmilovEvent notification happens after normal
506ad35a4c9SJonathan Lemonsignal delivery processing.
507ad35a4c9SJonathan Lemon.Va data
508ad35a4c9SJonathan Lemonreturns the number of times the signal has occurred since the last call to
509add06812SJonathan Lemon.Fn kevent .
51019eaed53SKonstantin BelousovThis filter automatically sets the
51119eaed53SKonstantin Belousov.Dv EV_CLEAR
51219eaed53SKonstantin Belousovflag internally.
51319eaed53SKonstantin Belousov.It Dv EVFILT_TIMER
514e725a129SJonathan LemonEstablishes an arbitrary timer identified by
515e725a129SJonathan Lemon.Va ident .
516e725a129SJonathan LemonWhen adding a timer,
517e725a129SJonathan Lemon.Va data
51842e62ecaSBaptiste Daroussinspecifies the timeout period.
51919eaed53SKonstantin BelousovThe timer will be periodic unless
52019eaed53SKonstantin Belousov.Dv EV_ONESHOT
52119eaed53SKonstantin Belousovis specified.
522e725a129SJonathan LemonOn return,
523e725a129SJonathan Lemon.Va data
524fea88e76SGuido van Rooijcontains the number of times the timeout has expired since the last call to
525e725a129SJonathan Lemon.Fn kevent .
526e725a129SJonathan LemonThis filter automatically sets the EV_CLEAR flag internally.
527d2b2cceaSCeri DaviesThere is a system wide limit on the number of timers
528d2b2cceaSCeri Davieswhich is controlled by the
529d2b2cceaSCeri Davies.Va kern.kq_calloutmax
530d2b2cceaSCeri Daviessysctl.
53119eaed53SKonstantin Belousov.Bl -tag -width "Dv NOTE_USECONDS"
53242e62ecaSBaptiste Daroussin.It Dv NOTE_SECONDS
53342e62ecaSBaptiste Daroussin.Va data
53442e62ecaSBaptiste Daroussinis in seconds.
53542e62ecaSBaptiste Daroussin.It Dv NOTE_MSECONDS
53642e62ecaSBaptiste Daroussin.Va data
53742e62ecaSBaptiste Daroussinis in milliseconds.
53842e62ecaSBaptiste Daroussin.It Dv NOTE_USECONDS
53942e62ecaSBaptiste Daroussin.Va data
54042e62ecaSBaptiste Daroussinis in microseconds.
54142e62ecaSBaptiste Daroussin.It Dv NOTE_NSECONDS
54242e62ecaSBaptiste Daroussin.Va data
54342e62ecaSBaptiste Daroussinis in nanoseconds.
54442e62ecaSBaptiste Daroussin.El
545bda16723SChristian Brueffer.Pp
54642e62ecaSBaptiste DaroussinIf
54742e62ecaSBaptiste Daroussin.Va fflags
548*17c847c1SKonstantin Belousovis not set, the default is milliseconds.
549*17c847c1SKonstantin BelousovOn return,
550bda16723SChristian Brueffer.Va fflags
551bda16723SChristian Brueffercontains the events which triggered the filter.
5522c2e4499SStacey Son.It Dv EVFILT_USER
5532c2e4499SStacey SonEstablishes a user event identified by
5542c2e4499SStacey Son.Va ident
555f6ac2391SJoel Dahlwhich is not associated with any kernel mechanism but is triggered by
5562c2e4499SStacey Sonuser level code.
5572c2e4499SStacey SonThe lower 24 bits of the
5582c2e4499SStacey Son.Va fflags
5592c2e4499SStacey Sonmay be used for user defined flags and manipulated using the following:
56019eaed53SKonstantin Belousov.Bl -tag -width "Dv NOTE_FFLAGSMASK"
5612c2e4499SStacey Son.It Dv NOTE_FFNOP
5622c2e4499SStacey SonIgnore the input
5632c2e4499SStacey Son.Va fflags .
5642c2e4499SStacey Son.It Dv NOTE_FFAND
5652c2e4499SStacey SonBitwise AND
5662c2e4499SStacey Son.Va fflags .
5672c2e4499SStacey Son.It Dv NOTE_FFOR
5682c2e4499SStacey SonBitwise OR
5692c2e4499SStacey Son.Va fflags .
57020df026cSRuslan Ermilov.It Dv NOTE_FFCOPY
5712c2e4499SStacey SonCopy
5722c2e4499SStacey Son.Va fflags .
5732c2e4499SStacey Son.It Dv NOTE_FFCTRLMASK
5742c2e4499SStacey SonControl mask for
5752c2e4499SStacey Son.Va fflags .
5762c2e4499SStacey Son.It Dv NOTE_FFLAGSMASK
5772c2e4499SStacey SonUser defined flag mask for
5782c2e4499SStacey Son.Va fflags .
5792c2e4499SStacey Son.El
5802c2e4499SStacey Son.Pp
5812c2e4499SStacey SonA user event is triggered for output with the following:
58219eaed53SKonstantin Belousov.Bl -tag -width "Dv NOTE_FFLAGSMASK"
5832c2e4499SStacey Son.It Dv NOTE_TRIGGER
5842c2e4499SStacey SonCause the event to be triggered.
5852c2e4499SStacey Son.El
5862c2e4499SStacey Son.Pp
5872c2e4499SStacey SonOn return,
5882c2e4499SStacey Son.Va fflags
5892c2e4499SStacey Soncontains the users defined flags in the lower 24 bits.
590ad35a4c9SJonathan Lemon.El
591b072e86dSKonstantin Belousov.Sh CANCELLATION BEHAVIOUR
592b072e86dSKonstantin BelousovIf
593b072e86dSKonstantin Belousov.Fa nevents
594b072e86dSKonstantin Belousovis non-zero, i.e. the function is potentially blocking, the call
595b072e86dSKonstantin Belousovis a cancellation point.
596b072e86dSKonstantin BelousovOtherwise, i.e. if
597b072e86dSKonstantin Belousov.Fa nevents
598b072e86dSKonstantin Belousovis zero, the call is not cancellable.
599b072e86dSKonstantin BelousovCancellation can only occur before any changes are made to the kqueue,
600b072e86dSKonstantin Belousovor when the call was blocked and no changes to the queue were requested.
601ad35a4c9SJonathan Lemon.Sh RETURN VALUES
6022faeeff4SRuslan ErmilovThe
603af7b56f4SJohn-Mark Gurney.Fn kqueue
6042faeeff4SRuslan Ermilovsystem call
605af7b56f4SJohn-Mark Gurneycreates a new kernel event queue and returns a file descriptor.
606af7b56f4SJohn-Mark GurneyIf there was an error creating the kernel event queue, a value of -1 is
607af7b56f4SJohn-Mark Gurneyreturned and errno set.
608af7b56f4SJohn-Mark Gurney.Pp
6092faeeff4SRuslan ErmilovThe
610ad35a4c9SJonathan Lemon.Fn kevent
6112faeeff4SRuslan Ermilovsystem call
612ad35a4c9SJonathan Lemonreturns the number of events placed in the
613bb33e422SChris Costello.Fa eventlist ,
614ad35a4c9SJonathan Lemonup to the value given by
615bb33e422SChris Costello.Fa nevents .
616ad35a4c9SJonathan LemonIf an error occurs while processing an element of the
617bb33e422SChris Costello.Fa changelist
618ad35a4c9SJonathan Lemonand there is enough room in the
619bb33e422SChris Costello.Fa eventlist ,
620ad35a4c9SJonathan Lemonthen the event will be placed in the
621bb33e422SChris Costello.Fa eventlist
622ad35a4c9SJonathan Lemonwith
623ad35a4c9SJonathan Lemon.Dv EV_ERROR
624ad35a4c9SJonathan Lemonset in
625ad35a4c9SJonathan Lemon.Va flags
626ad35a4c9SJonathan Lemonand the system error in
627ad35a4c9SJonathan Lemon.Va data .
628ad35a4c9SJonathan LemonOtherwise,
629ad35a4c9SJonathan Lemon.Dv -1
630ad35a4c9SJonathan Lemonwill be returned, and
631ad35a4c9SJonathan Lemon.Dv errno
632ad35a4c9SJonathan Lemonwill be set to indicate the error condition.
633ad35a4c9SJonathan LemonIf the time limit expires, then
634ad35a4c9SJonathan Lemon.Fn kevent
635ad35a4c9SJonathan Lemonreturns 0.
6368c231786SBenedict Reuschling.Sh EXAMPLES
6378c231786SBenedict Reuschling.Bd -literal -compact
6388c231786SBenedict Reuschling#include <sys/event.h>
6398c231786SBenedict Reuschling#include <err.h>
6408c231786SBenedict Reuschling#include <fcntl.h>
6418c231786SBenedict Reuschling#include <stdio.h>
6428c231786SBenedict Reuschling#include <stdlib.h>
6438c231786SBenedict Reuschling#include <string.h>
6448c231786SBenedict Reuschling
6458c231786SBenedict Reuschlingint
6468c231786SBenedict Reuschlingmain(int argc, char **argv)
6478c231786SBenedict Reuschling{
6488c231786SBenedict Reuschling    struct kevent event;    /* Event we want to monitor */
6498c231786SBenedict Reuschling    struct kevent tevent;   /* Event triggered */
6508c231786SBenedict Reuschling    int kq, fd, ret;
6518c231786SBenedict Reuschling
6528c231786SBenedict Reuschling    if (argc != 2)
6538c231786SBenedict Reuschling	err(EXIT_FAILURE, "Usage: %s path\en", argv[0]);
6548c231786SBenedict Reuschling    fd = open(argv[1], O_RDONLY);
6558c231786SBenedict Reuschling    if (fd == -1)
6568c231786SBenedict Reuschling	err(EXIT_FAILURE, "Failed to open '%s'", argv[1]);
6578c231786SBenedict Reuschling
6588c231786SBenedict Reuschling    /* Create kqueue. */
6598c231786SBenedict Reuschling    kq = kqueue();
6608c231786SBenedict Reuschling    if (kq == -1)
6618c231786SBenedict Reuschling	err(EXIT_FAILURE, "kqueue() failed");
6628c231786SBenedict Reuschling
6638c231786SBenedict Reuschling    /* Initialize kevent structure. */
6648c231786SBenedict Reuschling    EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE,
6658c231786SBenedict Reuschling	0, NULL);
6668c231786SBenedict Reuschling    /* Attach event to the kqueue. */
6678c231786SBenedict Reuschling    ret = kevent(kq, &event, 1, NULL, 0, NULL);
6688c231786SBenedict Reuschling    if (ret == -1)
6698c231786SBenedict Reuschling	err(EXIT_FAILURE, "kevent register");
6708c231786SBenedict Reuschling    if (event.flags & EV_ERROR)
6718c231786SBenedict Reuschling	errx(EXIT_FAILURE, "Event error: %s", strerror(event.data));
6728c231786SBenedict Reuschling
6738c231786SBenedict Reuschling    for (;;) {
6748c231786SBenedict Reuschling	/* Sleep until something happens. */
6758c231786SBenedict Reuschling	ret = kevent(kq, NULL, 0, &tevent, 1, NULL);
6768c231786SBenedict Reuschling	if (ret == -1) {
6778c231786SBenedict Reuschling	    err(EXIT_FAILURE, "kevent wait");
6788c231786SBenedict Reuschling	} else if (ret > 0) {
6798c231786SBenedict Reuschling	    printf("Something was written in '%s'\en", argv[1]);
6808c231786SBenedict Reuschling	}
6818c231786SBenedict Reuschling    }
6828c231786SBenedict Reuschling}
6838c231786SBenedict Reuschling.Ed
684ad35a4c9SJonathan Lemon.Sh ERRORS
685ad35a4c9SJonathan LemonThe
686af7b56f4SJohn-Mark Gurney.Fn kqueue
6872faeeff4SRuslan Ermilovsystem call fails if:
688af7b56f4SJohn-Mark Gurney.Bl -tag -width Er
689af7b56f4SJohn-Mark Gurney.It Bq Er ENOMEM
690af7b56f4SJohn-Mark GurneyThe kernel failed to allocate enough memory for the kernel queue.
6911947c8a6SJilles Tjoelker.It Bq Er ENOMEM
6921947c8a6SJilles TjoelkerThe
6931947c8a6SJilles Tjoelker.Dv RLIMIT_KQUEUES
6941947c8a6SJilles Tjoelkerrlimit
6951947c8a6SJilles Tjoelker(see
6961947c8a6SJilles Tjoelker.Xr getrlimit 2 )
6971947c8a6SJilles Tjoelkerfor the current user would be exceeded.
698af7b56f4SJohn-Mark Gurney.It Bq Er EMFILE
699af7b56f4SJohn-Mark GurneyThe per-process descriptor table is full.
700af7b56f4SJohn-Mark Gurney.It Bq Er ENFILE
701af7b56f4SJohn-Mark GurneyThe system file table is full.
702af7b56f4SJohn-Mark Gurney.El
703af7b56f4SJohn-Mark Gurney.Pp
704af7b56f4SJohn-Mark GurneyThe
705ad35a4c9SJonathan Lemon.Fn kevent
7062faeeff4SRuslan Ermilovsystem call fails if:
707ad35a4c9SJonathan Lemon.Bl -tag -width Er
708c23155a4SRuslan Ermilov.It Bq Er EACCES
709ad35a4c9SJonathan LemonThe process does not have permission to register a filter.
710ad35a4c9SJonathan Lemon.It Bq Er EFAULT
711ad35a4c9SJonathan LemonThere was an error reading or writing the
712ad35a4c9SJonathan Lemon.Va kevent
713ad35a4c9SJonathan Lemonstructure.
714ad35a4c9SJonathan Lemon.It Bq Er EBADF
715ad35a4c9SJonathan LemonThe specified descriptor is invalid.
716ad35a4c9SJonathan Lemon.It Bq Er EINTR
717ad35a4c9SJonathan LemonA signal was delivered before the timeout expired and before any
718ad35a4c9SJonathan Lemonevents were placed on the kqueue for return.
719b072e86dSKonstantin Belousov.It Bq Er EINTR
720b072e86dSKonstantin BelousovA cancellation request was delivered to the thread, but not yet handled.
721ad35a4c9SJonathan Lemon.It Bq Er EINVAL
722ad35a4c9SJonathan LemonThe specified time limit or filter is invalid.
723b275c430SJonathan Lemon.It Bq Er ENOENT
724b275c430SJonathan LemonThe event could not be found to be modified or deleted.
725ad35a4c9SJonathan Lemon.It Bq Er ENOMEM
726d2b2cceaSCeri DaviesNo memory was available to register the event
727d2b2cceaSCeri Daviesor, in the special case of a timer, the maximum number of
728d2b2cceaSCeri Daviestimers has been exceeded.
729d2b2cceaSCeri DaviesThis maximum is configurable via the
730d2b2cceaSCeri Davies.Va kern.kq_calloutmax
731d2b2cceaSCeri Daviessysctl.
732ad35a4c9SJonathan Lemon.It Bq Er ESRCH
733ad35a4c9SJonathan LemonThe specified process to attach to does not exist.
734ad35a4c9SJonathan Lemon.El
735b072e86dSKonstantin Belousov.Pp
736b072e86dSKonstantin BelousovWhen
737b072e86dSKonstantin Belousov.Fn kevent
738b072e86dSKonstantin Belousovcall fails with
739b072e86dSKonstantin Belousov.Er EINTR
740b072e86dSKonstantin Belousoverror, all changes in the
741b072e86dSKonstantin Belousov.Fa changelist
742b072e86dSKonstantin Belousovhave been applied.
743ad35a4c9SJonathan Lemon.Sh SEE ALSO
744ad35a4c9SJonathan Lemon.Xr aio_error 2 ,
745ad35a4c9SJonathan Lemon.Xr aio_read 2 ,
746ad35a4c9SJonathan Lemon.Xr aio_return 2 ,
747ad35a4c9SJonathan Lemon.Xr poll 2 ,
748ad35a4c9SJonathan Lemon.Xr read 2 ,
749ad35a4c9SJonathan Lemon.Xr select 2 ,
750ad35a4c9SJonathan Lemon.Xr sigaction 2 ,
7513c63f48cSSheldon Hearn.Xr write 2 ,
752b072e86dSKonstantin Belousov.Xr pthread_setcancelstate 3 ,
7533c63f48cSSheldon Hearn.Xr signal 3
754ad35a4c9SJonathan Lemon.Sh HISTORY
755ad35a4c9SJonathan LemonThe
756ad35a4c9SJonathan Lemon.Fn kqueue
757ad35a4c9SJonathan Lemonand
758ad35a4c9SJonathan Lemon.Fn kevent
7592faeeff4SRuslan Ermilovsystem calls first appeared in
76055b8fbfbSJohn-Mark Gurney.Fx 4.1 .
7614451bb5dSJonathan Lemon.Sh AUTHORS
762ad35a4c9SJonathan LemonThe
763ad35a4c9SJonathan Lemon.Fn kqueue
764ad35a4c9SJonathan Lemonsystem and this manual page were written by
7658fbf3d50SBaptiste Daroussin.An Jonathan Lemon Aq Mt [email protected] .
766e585cdf0SJohn-Mark Gurney.Sh BUGS
767bda16723SChristian BruefferThe
7683b38d66bSColin Percival.Fa timeout
7693b38d66bSColin Percivalvalue is limited to 24 hours; longer timeouts will be silently
7703b38d66bSColin Percivalreinterpreted as 24 hours.
7718eb15797SEd Schouten.Pp
7728eb15797SEd SchoutenPrevious versions of
7738eb15797SEd Schouten.In sys/event.h
7748eb15797SEd Schoutenfail to parse without including
7758eb15797SEd Schouten.In sys/types.h
7768eb15797SEd Schoutenmanually.
777