xref: /xnu-11215/bsd/man/man2/kqueue.2 (revision 5c2921b0)
1.\"
2.\" Copyright (c) 2008-2016 Apple Inc.  All rights reserved.
3.\"
4.\" @APPLE_LICENSE_HEADER_START@
5.\"
6.\" This file contains Original Code and/or Modifications of Original Code
7.\" as defined in and that are subject to the Apple Public Source License
8.\" Version 2.0 (the 'License'). You may not use this file except in
9.\" compliance with the License. Please obtain a copy of the License at
10.\" http://www.opensource.apple.com/apsl/ and read it before using this
11.\" file.
12.\"
13.\" The Original Code and all software distributed under the License are
14.\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17.\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18.\" Please see the License for the specific language governing rights and
19.\" limitations under the License.
20.\"
21.\" @APPLE_LICENSE_HEADER_END@
22.\"
23.\"
24.\" Copyright (c) 2000 Jonathan Lemon
25.\" All rights reserved.
26.\"
27.\" Redistribution and use in source and binary forms, with or without
28.\" modification, are permitted provided that the following conditions
29.\" are met:
30.\" 1. Redistributions of source code must retain the above copyright
31.\"    notice, this list of conditions and the following disclaimer.
32.\" 2. Redistributions in binary form must reproduce the above copyright
33.\"    notice, this list of conditions and the following disclaimer in the
34.\"    documentation and/or other materials provided with the distribution.
35.\"
36.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND
37.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
40.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
42.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
44.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46.\" SUCH DAMAGE.
47.\"
48.\" $FreeBSD: src/lib/libc/sys/kqueue.2,v 1.32 2002/12/19 09:40:25 ru Exp $
49.\"
50.Dd October 21, 2008
51.Dt KQUEUE 2
52.Os
53.Sh NAME
54.Nm kqueue ,
55.Nm kevent ,
56.Nm kevent64
57and
58.Nm kevent_qos
59.Nd kernel event notification mechanism
60.Sh LIBRARY
61.Lb libc
62.Sh SYNOPSIS
63.In sys/types.h
64.In sys/event.h
65.In sys/time.h
66.Ft int
67.Fn kqueue "void"
68.Ft int
69.Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout"
70.Ft int
71.Fn kevent64 "int kq" "const struct kevent64_s *changelist" "int nchanges" "struct kevent64_s *eventlist" "int nevents" "unsigned int flags" "const struct timespec *timeout"
72.Ft int
73.Fn kevent_qos "int kq" "const struct kevent_qos_s *changelist" "int nchanges" "struct kevent_qos_s *eventlist" "int nevents" "void *data_out" "size_t *data_available" "unsigned int flags"
74.Fn EV_SET "&kev" ident filter flags fflags data udata
75.Fn EV_SET64 "&kev" ident filter flags fflags data udata "ext[0]" "ext[1]"
76.Fn EV_SET_QOS "&kev" ident filter flags qos udata fflags xflags data "ext[0]" "ext[1]" "ext[2]" "ext[3]"
77.Sh DESCRIPTION
78The
79.Fn kqueue
80system call allocates a kqueue file descriptor.  This file descriptor
81provides a generic method of notifying the user when a kernel
82event (kevent) happens or a condition holds, based on the results
83of small pieces of kernel code termed filters.
84.Pp
85A kevent is identified by an (ident, filter, and optional udata value)
86tuple.  It specifies the interesting conditions to be notified about
87for that tuple. An (ident, filter, and optional udata value) tuple can
88only appear once in a given kqueue.
89Subsequent attempts to register the same tuple for a given kqueue
90will result in the replacement of the conditions being watched,
91not an addition.
92Whether the udata value is considered as part of the tuple is controlled
93by the EV_UDATA_SPECIFIC flag on the kevent.
94.Pp
95The filter identified in a kevent is executed upon the initial
96registration of that event in order to detect whether a preexisting
97condition is present, and is also executed whenever an event is
98passed to the filter for evaluation.
99If the filter determines that the condition should be reported,
100then the kevent is placed on the kqueue for the user to retrieve.
101.Pp
102The filter is also run when the user attempts to retrieve the kevent
103from the kqueue.
104If the filter indicates that the condition that triggered
105the event no longer holds, the kevent is removed from the kqueue and
106is not returned.
107.Pp
108Multiple events which trigger the filter do not result in multiple
109kevents being placed on the kqueue; instead, the filter will aggregate
110the events into a single struct kevent.
111Calling
112.Fn close
113on a file descriptor will remove any kevents that reference the descriptor.
114.Pp
115The
116.Fn kqueue
117system call
118creates a new kernel event queue and returns a descriptor.
119The queue is not inherited by a child created with
120.Xr fork 2 .
121.Pp
122The
123.Fn kevent,
124.Fn kevent64
125and
126.Fn kevent_qos
127system calls
128are used to register events with the queue, and return any pending
129events to the user.
130The
131.Fa changelist
132argument
133is a pointer to an array of
134.Va kevent,
135.Va kevent64_s
136or
137.Va kevent_qos_s
138structures, as defined in
139.Aq Pa sys/event.h .
140All changes contained in the
141.Fa changelist
142are applied before any pending events are read from the queue.
143The
144.Fa nchanges
145argument
146gives the size of
147.Fa changelist .
148.Pp
149The
150.Fa eventlist
151argument
152is a pointer to an array of out
153.Va kevent,
154.Va kevent64_s
155or
156.Va kevent_qos_s
157structures.
158The
159.Fa nevents
160argument determines the size of
161.Fa eventlist .
162.Pp
163The
164.Fa data_out
165argument provides space for extra out data provided by specific filters.
166The
167.Fa data_available
168argument's contents specified the space available in the data pool on input,
169and contains the amount still remaining on output.
170If the KEVENT_FLAG_STACK_DATA flag is specified on the system call,
171the data is allocated from the pool in stack order instead of typical heap order.
172.Pp
173If
174.Fa timeout
175is a non-NULL pointer, it specifies a maximum interval to wait
176for an event, which will be interpreted as a struct timespec.  If
177.Fa timeout
178is a NULL pointer, both
179.Fn kevent
180and
181.Fn kevent64
182wait indefinitely.  To effect a poll, the
183.Fa flags
184argument to
185.Fn kevent64
186or
187.Fn kevent_qos
188can include the KEVENT_FLAG_IMMEDIATE value to indicate an
189immediate timeout.  Alternatively, the
190.Fa timeout
191argument should be non-NULL, pointing to a zero-valued
192.Va timespec
193structure.  The same array may be used for the
194.Fa changelist
195and
196.Fa eventlist .
197.Pp
198The
199.Fn EV_SET
200macro is provided for ease of initializing a
201.Va kevent
202structure. Similarly,
203.Fn EV_SET64
204initializes a
205.Va kevent64_s
206structure and
207.Fn EV_SET_QOS
208initializes a
209.Va kevent_qos_s
210structure.
211.Pp
212The
213.Va kevent,
214.Va kevent64_s
215and
216.Va kevent_qos_s
217structures are defined as:
218.Bd -literal
219struct kevent {
220	uintptr_t 	ident;		/* identifier for this event */
221	int16_t		filter;		/* filter for event */
222	uint16_t	flags;		/* general flags */
223	uint32_t	fflags;		/* filter-specific flags */
224	intptr_t  	data;		/* filter-specific data */
225	void		*udata;		/* opaque user data identifier */
226};
227
228struct kevent64_s {
229        uint64_t        ident;          /* identifier for this event */
230	int16_t         filter;         /* filter for event */
231	uint16_t        flags;          /* general flags */
232	uint32_t        fflags;         /* filter-specific flags */
233	int64_t         data;           /* filter-specific data */
234	uint64_t        udata;          /* opaque user data identifier */
235	uint64_t        ext[2];         /* filter-specific extensions */
236};
237
238struct kevent_qos_s {
239        uint64_t        ident;          /* identifier for this event */
240	int16_t         filter;         /* filter for event */
241	uint16_t        flags;          /* general flags */
242	uint32_t        qos;            /* quality of service when servicing event */
243	uint64_t        udata;          /* opaque user data identifier */
244	uint32_t        fflags;         /* filter-specific flags */
245	uint32_t        xflags;         /* extra filter-specific flags */
246	int64_t         data;           /* filter-specific data */
247	uint64_t        ext[4];         /* filter-specific extensions */
248};
249.Ed
250.Pp
251----
252.Pp
253The fields of
254.Fa struct kevent,
255.Fa struct kevent64_s
256and
257.Fa struct kevent_qos_s
258are:
259.Bl -tag -width XXXfilter
260.It ident
261Value used to identify the source of the event.
262The exact interpretation is determined by the attached filter,
263but often is a file descriptor.
264.It filter
265Identifies the kernel filter used to process this event.  The pre-defined
266system filters are described below.
267.It flags
268Actions to perform on the event.
269.It fflags
270Filter-specific flags.
271.It data
272Filter-specific data value.
273.It udata
274Opaque user-defined value passed through the kernel unchanged. It can
275optionally be part of the uniquing decision of the kevent system
276.El
277.Pp
278In addition,
279.Fa struct kevent64_s
280contains:
281.Bl -tag -width XXXfilter
282.It ext[2]
283This field stores extensions for the event's filter. What type of extension depends on
284what type of filter is being used.
285.El
286.Pp
287In addition,
288.Fa struct kevent_qos_s
289contains:
290.Bl -tag -width XXXfilter
291.It xflags
292Extra filter-specific flags.
293.It ext[4]
294The QoS variant provides twice as many extension values for filter-specific uses.
295.El
296.Pp
297----
298.Pp
299The
300.Va flags
301field can contain the following values:
302.Bl -tag -width XXXEV_ONESHOT
303.It EV_ADD
304Adds the event to the kqueue.  Re-adding an existing event
305will modify the parameters of the original event, and not result
306in a duplicate entry.  Adding an event automatically enables it,
307unless overridden by the EV_DISABLE flag.
308.It EV_ENABLE
309Permit
310.Fn kevent,
311.Fn kevent64
312and
313.Fn kevent_qos
314to return the event if it is triggered.
315.It EV_DISABLE
316Disable the event so
317.Fn kevent,
318.Fn kevent64
319and
320.Fn kevent_qos
321will not return it.  The filter itself is not disabled.
322.It EV_DELETE
323Removes the event from the kqueue.  Events which are attached to
324file descriptors are automatically deleted on the last close of
325the descriptor.
326.It EV_RECEIPT
327This flag is useful for making bulk changes to a kqueue without draining any
328pending events. When passed as input, it forces EV_ERROR to always be returned.
329When a filter is successfully added, the
330.Va data
331field will be zero.
332.It EV_ONESHOT
333Causes the event to return only the first occurrence of the filter
334being triggered.  After the user retrieves the event from the kqueue,
335it is deleted.
336.It EV_CLEAR
337After the event is retrieved by the user, its state is reset.
338This is useful for filters which report state transitions
339instead of the current state.  Note that some filters may automatically
340set this flag internally.
341.It EV_EOF
342Filters may set this flag to indicate filter-specific EOF condition.
343.It EV_OOBAND
344Read filter on socket may set this flag to indicate the presence of out of
345band data on the descriptor.
346.It EV_ERROR
347See
348.Sx RETURN VALUES
349below.
350.El
351.Pp
352----
353.Pp
354The predefined system filters are listed below.
355Arguments may be passed to and from the filter via the
356.Va data,
357.Va fflags
358and optionally
359.Va xflags
360fields in the
361.Va kevent,
362.Va kevent64_s
363or
364.Va kevent_qos_s
365structure.
366.Bl -tag -width EVFILT_MACHPORT
367.It EVFILT_READ
368Takes a file descriptor as the identifier, and returns whenever
369there is data available to read.
370The behavior of the filter is slightly different depending
371on the descriptor type.
372.Pp
373.Bl -tag -width 2n
374.It Sockets
375Sockets which have previously been passed to
376.Fn listen
377return when there is an incoming connection pending.
378.Va data
379contains the size of the listen backlog.
380.Pp
381Other socket descriptors return when there is data to be read,
382subject to the
383.Dv SO_RCVLOWAT
384value of the socket buffer.
385This may be overridden with a per-filter low water mark at the
386time the filter is added by setting the
387NOTE_LOWAT
388flag in
389.Va fflags ,
390and specifying the new low water mark in
391.Va data .
392The derived per filter low water mark value is, however, bounded
393by socket receive buffer's high and low water mark values.
394On return,
395.Va data
396contains the number of bytes of protocol data available to read.
397.Pp
398The presence of EV_OOBAND in
399.Va flags ,
400indicates the presence of out of band data on the socket
401.Va data
402equal to the potential number of OOB bytes availble to read.
403.Pp
404If the read direction of the socket has shutdown, then the filter
405also sets EV_EOF in
406.Va flags ,
407and returns the socket error (if any) in
408.Va fflags .
409It is possible for EOF to be returned (indicating the connection is gone)
410while there is still data pending in the socket buffer.
411.It Vnodes
412Returns when the file pointer is not at the end of file.
413.Va data
414contains the offset from current position to end of file,
415and may be negative.
416.It "Fifos, Pipes"
417Returns when there is data to read;
418.Va data
419contains the number of bytes available.
420.Pp
421When the last writer disconnects, the filter will set EV_EOF in
422.Va flags .
423This may be cleared by passing in EV_CLEAR, at which point the
424filter will resume waiting for data to become available before
425returning.
426.It "Device nodes"
427Returns when there is data to read from the device;
428.Va data
429contains the number of bytes available.  If the device does
430not support returning number of bytes, it will not allow the
431filter to be attached.  However, if the NOTE_LOWAT flag is
432specified and the
433.Va data
434field contains 1 on input, those devices will attach - but
435cannot be relied upon to provide an accurate count of bytes
436to be read on output.
437.El
438.It Dv EVFILT_EXCEPT
439Takes a descriptor as the identifier, and returns whenever one of the
440specified exceptional conditions has occurred on the descriptor. Conditions
441are specified in
442.Va fflags .
443Currently, this filter can be used to monitor the arrival of
444out-of-band data on a socket descriptor using the filter flag
445.Dv NOTE_OOB .
446.Pp
447If the read direction of the socket has shutdown, then the filter
448also sets EV_EOF in
449.Va flags ,
450and returns the socket error (if any) in
451.Va fflags .
452.It EVFILT_WRITE
453Takes a file descriptor as the identifier, and returns whenever
454it is possible to write to the descriptor.  For sockets, pipes
455and fifos,
456.Va data
457will contain the amount of space remaining in the write buffer.
458The filter will set EV_EOF when the reader disconnects, and for
459the fifo case, this may be cleared by use of EV_CLEAR.
460Note that this filter is not supported for vnodes.
461.Pp
462For sockets, the low water mark and socket error handling is
463identical to the EVFILT_READ case.
464.It EVFILT_AIO
465This filter is currently unsupported.
466.\"The sigevent portion of the AIO request is filled in, with
467.\".Va sigev_notify_kqueue
468.\"containing the descriptor of the kqueue that the event should
469.\"be attached to,
470.\".Va sigev_value
471.\"containing the udata value, and
472.\".Va sigev_notify
473.\"set to SIGEV_KEVENT.
474.\"When the
475.\".Fn aio_*
476.\"system call is made, the event will be registered
477.\"with the specified kqueue, and the
478.\".Va ident
479.\"argument set to the
480.\".Fa struct aiocb
481.\"returned by the
482.\".Fn aio_*
483.\"system call.
484.\"The filter returns under the same conditions as aio_error.
485.\".Pp
486.\"Alternatively, a kevent structure may be initialized, with
487.\".Va ident
488.\"containing the descriptor of the kqueue, and the
489.\"address of the kevent structure placed in the
490.\".Va aio_lio_opcode
491.\"field of the AIO request.  However, this approach will not work on
492.\"architectures with 64-bit pointers, and should be considered deprecated.
493.It EVFILT_VNODE
494Takes a file descriptor as the identifier and the events to watch for in
495.Va fflags ,
496and returns when one or more of the requested events occurs on the descriptor.
497The events to monitor are:
498.Bl -tag -width XXNOTE_RENAME
499.It NOTE_DELETE
500The
501.Fn unlink
502system call
503was called on the file referenced by the descriptor.
504.It NOTE_WRITE
505A write occurred on the file referenced by the descriptor.
506.It NOTE_EXTEND
507The file referenced by the descriptor was extended.
508.It NOTE_ATTRIB
509The file referenced by the descriptor had its attributes changed.
510.It NOTE_LINK
511The link count on the file changed.
512.It NOTE_RENAME
513The file referenced by the descriptor was renamed.
514.It NOTE_REVOKE
515Access to the file was revoked via
516.Xr revoke 2
517or the underlying fileystem was unmounted.
518.It NOTE_FUNLOCK
519The file was unlocked by calling
520.Xr flock 2
521or
522.Xr close 2
523.It NOTE_LEASE_DOWNGRADE
524A lease break to downgrade the lease to read lease is requested on the file referenced by the descriptor.
525.It NOTE_LEASE_RELEASE
526A lease break to release the lease is requested on the file or directory referenced by the descriptor.
527.El
528.Pp
529On return,
530.Va fflags
531contains the filter-specific flags which are associated with
532the triggered events seen by this filter.
533.It EVFILT_PROC
534Takes the process ID to monitor as the identifier and the events to watch for
535in
536.Va fflags ,
537and returns when the process performs one or more of the requested events.
538If a process can normally see another process, it can attach an event to it.
539The events to monitor are:
540.Bl -tag -width NOTE_SIGNAL
541.It NOTE_EXIT
542The process has exited.
543.It NOTE_EXITSTATUS
544The process has exited and its exit status is in filter specific data. Valid only on child processes and to be used along with NOTE_EXIT.
545.It NOTE_FORK
546The process created a child process via
547.Xr fork 2
548or similar call.
549.It NOTE_EXEC
550The process executed a new process via
551.Xr execve 2
552or similar call.
553.It NOTE_SIGNAL
554The process was sent a signal. Status can be checked via
555.Xr waitpid 2
556or similar call.
557.It NOTE_REAP
558The process was reaped by the parent via
559.Xr wait 2
560or similar call. Deprecated, use NOTE_EXIT.
561.El
562.Pp
563On return,
564.Va fflags
565contains the events which triggered the filter.
566.It EVFILT_SIGNAL
567Takes the signal number to monitor as the identifier and returns
568when the given signal is generated for the process.
569This coexists with the
570.Fn signal
571and
572.Fn sigaction
573facilities, and has a lower precedence.  Only signals sent to the process,
574not to a particular thread, will trigger the filter. The filter will record
575all attempts to deliver a signal to a process, even if the signal has
576been marked as SIG_IGN.  Event notification happens before normal
577signal delivery processing.
578.Va data
579returns the number of times the signal has been generated since the last call to
580.Fn kevent .
581This filter automatically sets the EV_CLEAR flag internally.
582.It EVFILT_MACHPORT
583Takes the name of a mach port, or port set, in
584.Va ident
585and waits until a message is enqueued on the port or port set. When a message
586is detected, but not directly received by the kevent call, the name of the
587specific port where the message is enqueued is returned in
588.Va data .
589If
590.Va fflags
591contains MACH_RCV_MSG, the ext[0] and ext[1] flags are assumed to contain
592a pointer to the buffer where the message is to be received and the size
593of the receive buffer, respectively.  If MACH_RCV_MSG is specifed, yet the
594buffer size in ext[1] is zero, The space for the buffer may be carved out
595of the
596.Va
597data_out
598area provided to
599.Fn kevent_qos
600if there is enough space remaining there.
601.It EVFILT_TIMER
602Establishes an interval timer identified by
603.Va ident
604where
605.Va data
606specifies the timeout period (in milliseconds).
607.Pp
608.Va fflags
609can include one of the following flags to specify a different unit:
610.Bl -tag -width NOTE_NSECONDS
611.It NOTE_SECONDS
612.Va data
613is in seconds
614.It NOTE_USECONDS
615.Va data
616is in microseconds
617.It NOTE_NSECONDS
618.Va data
619is in nanoseconds
620.It NOTE_MACHTIME
621.Va data
622is in Mach absolute time units
623.El
624.Pp
625.Va fflags
626can also include
627.Dv NOTE_ABSOLUTE,
628which establishes an
629.Dv EV_ONESHOT
630timer with an absolute deadline instead of an interval.
631The absolute deadline is expressed in terms of
632.Xr gettimeofday 2 .
633With
634.Dv NOTE_MACHTIME,
635the deadline is expressed in terms of
636.Fn mach_absolute_time .
637.Pp
638The timer can be coalesced with other timers to save power. The following flags can be set in
639.Va fflags
640to modify this behavior:
641.Bl -tag -width NOTE_BACKGROUND
642.It NOTE_CRITICAL
643override default power-saving techniques to more strictly respect the leeway value
644.It NOTE_BACKGROUND
645apply more power-saving techniques to coalesce this timer with other timers
646.It NOTE_LEEWAY
647.Va ext[1]
648holds user-supplied slop in deadline for timer coalescing.
649.El
650.Pp
651The timer will be periodic unless
652.Dv EV_ONESHOT
653is specified.
654On return,
655.Va data
656contains the number of times the timeout has expired since the last arming or last delivery of the timer event.
657.Pp
658This filter automatically sets the
659.Dv EV_CLEAR
660flag.
661.El
662.Pp
663----
664.Pp
665In the
666.Va ext[2]
667field of the
668.Va kevent64_s
669struture,
670.Va ext[0]
671is only used with the EVFILT_MACHPORT filter.
672With other filters,
673.Va ext[0]
674is passed through
675.Fn kevent64
676much like
677.Va udata .
678.Va ext[1]
679can always be used like
680.Va udata .
681For the use of ext[0], see the EVFILT_MACHPORT filter above.
682.Sh RETURN VALUES
683The
684.Fn kqueue
685system call
686creates a new kernel event queue and returns a file descriptor.
687If there was an error creating the kernel event queue, a value of -1 is
688returned and errno set.
689.Pp
690The
691.Fn kevent ,
692.Fn kevent64
693and
694.Fn kevent_qos
695system calls
696return the number of events placed in the
697.Fa eventlist ,
698up to the value given by
699.Fa nevents .
700If an error occurs while processing an element of the
701.Fa changelist
702and there is enough room in the
703.Fa eventlist ,
704then the event will be placed in the
705.Fa eventlist
706with
707.Dv EV_ERROR
708set in
709.Va flags
710and the system error in
711.Va data .
712Otherwise,
713.Dv -1
714will be returned, and
715.Dv errno
716will be set to indicate the error condition.
717If the time limit expires, then
718.Fn kevent ,
719.Fn kevent64
720and
721.Fn kevent_qos
722return 0.
723.Sh ERRORS
724The
725.Fn kqueue
726system call fails if:
727.Bl -tag -width Er
728.It Bq Er ENOMEM
729The kernel failed to allocate enough memory for the kernel queue.
730.It Bq Er EMFILE
731The per-process descriptor table is full.
732.It Bq Er ENFILE
733The system file table is full.
734.El
735.Pp
736The
737.Fn kevent
738and
739.Fn kevent64
740system calls fail if:
741.Bl -tag -width Er
742.It Bq Er EACCES
743The process does not have permission to register a filter.
744.It Bq Er EFAULT
745There was an error reading or writing the
746.Va kevent
747or
748.Va kevent64_s
749structure.
750.It Bq Er EBADF
751The specified descriptor is invalid.
752.It Bq Er EINTR
753A signal was delivered before the timeout expired and before any
754events were placed on the kqueue for return.
755.It Bq Er EINVAL
756The specified time limit or filter is invalid.
757.It Bq Er ENOENT
758The event could not be found to be modified or deleted.
759.It Bq Er ENOMEM
760No memory was available to register the event.
761.It Bq Er ESRCH
762The specified process to attach to does not exist.
763.El
764.Sh SEE ALSO
765.Xr aio_error 2 ,
766.Xr aio_read 2 ,
767.Xr aio_return 2 ,
768.Xr read 2 ,
769.Xr select 2 ,
770.Xr sigaction 2 ,
771.Xr write 2 ,
772.Xr signal 3
773.Sh HISTORY
774The
775.Fn kqueue
776and
777.Fn kevent
778system calls first appeared in
779.Fx 4.1 .
780.Sh AUTHORS
781The
782.Fn kqueue
783system and this manual page were written by
784.An Jonathan Lemon Aq [email protected] .
785.Sh BUGS
786Not all filesystem types support kqueue-style notifications.
787And even some that do, like some remote filesystems, may only
788support a subset of the notification semantics described
789here.
790