xref: /freebsd-13-stable/lib/libc/sys/kqueue.2 (revision b144e70a3325e033163aa4e6e15d0446e245702d)
1.\" Copyright (c) 2000 Jonathan Lemon
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd March 26, 2023
26.Dt KQUEUE 2
27.Os
28.Sh NAME
29.Nm kqueue ,
30.Nm kevent
31.Nd kernel event notification mechanism
32.Sh LIBRARY
33.Lb libc
34.Sh SYNOPSIS
35.In sys/event.h
36.Ft int
37.Fn kqueue "void"
38.Ft int
39.Fn kqueuex "u_int flags"
40.Ft int
41.Fo kevent
42.Fa "int kq"
43.Fa "const struct kevent *changelist"
44.Fa "int nchanges"
45.Fa "struct kevent *eventlist"
46.Fa "int nevents"
47.Fa "const struct timespec *timeout"
48.Fc
49.Fn EV_SET "kev" ident filter flags fflags data udata
50.Sh DESCRIPTION
51The
52.Fn kqueue
53system call
54provides a generic method of notifying the user when an event
55happens or a condition holds, based on the results of small
56pieces of kernel code termed filters.
57A kevent is identified by the (ident, filter) pair; there may only
58be one unique kevent per kqueue.
59.Pp
60The filter is executed upon the initial registration of a kevent
61in order to detect whether a preexisting condition is present, and is also
62executed whenever an event is passed to the filter for evaluation.
63If the filter determines that the condition should be reported,
64then the kevent is placed on the kqueue for the user to retrieve.
65.Pp
66The filter is also run when the user attempts to retrieve the kevent
67from the kqueue.
68If the filter indicates that the condition that triggered
69the event no longer holds, the kevent is removed from the kqueue and
70is not returned.
71.Pp
72Multiple events which trigger the filter do not result in multiple
73kevents being placed on the kqueue; instead, the filter will aggregate
74the events into a single struct kevent.
75Calling
76.Fn close
77on a file descriptor will remove any kevents that reference the descriptor.
78.Pp
79The
80.Fn kqueue
81system call
82creates a new kernel event queue and returns a descriptor.
83The queue is not inherited by a child created with
84.Xr fork 2 .
85However, if
86.Xr rfork 2
87is called without the
88.Dv RFFDG
89flag, then the descriptor table is shared,
90which will allow sharing of the kqueue between two processes.
91.Pp
92The
93.Fn kqueuex
94system call also creates a new kernel event queue, and additionally takes
95the
96.Fa flags
97argument, which is a bitwise-inclusive OR of the following flags:
98.Bl -tag -width "KQUEUE_CLOEXEC"
99.It Fa KQUEUE_CLOEXEC
100The returned file descriptor is automatically closed on
101.Xr execve 2
102.El
103The
104.Ql fd = kqueue()
105call is equivalent to
106.Ql fd = kqueuex(0) .
107.Pp
108For compatibility with
109.Nx ,
110the
111.Fn kqueue1
112function is provided, which accepts the
113.Dv O_CLOEXEC
114flag with the expected semantic.
115.Pp
116The
117.Fn kevent
118system call
119is used to register events with the queue, and return any pending
120events to the user.
121The
122.Fa changelist
123argument
124is a pointer to an array of
125.Va kevent
126structures, as defined in
127.In sys/event.h .
128All changes contained in the
129.Fa changelist
130are applied before any pending events are read from the queue.
131The
132.Fa nchanges
133argument
134gives the size of
135.Fa changelist .
136The
137.Fa eventlist
138argument
139is a pointer to an array of kevent structures.
140The
141.Fa nevents
142argument
143determines the size of
144.Fa eventlist .
145When
146.Fa nevents
147is zero,
148.Fn kevent
149will return immediately even if there is a
150.Fa timeout
151specified unlike
152.Xr select 2 .
153If
154.Fa timeout
155is a non-NULL pointer, it specifies a maximum interval to wait
156for an event, which will be interpreted as a struct timespec.
157If
158.Fa timeout
159is a NULL pointer,
160.Fn kevent
161waits indefinitely.
162To effect a poll, the
163.Fa timeout
164argument should be non-NULL, pointing to a zero-valued
165.Va timespec
166structure.
167The same array may be used for the
168.Fa changelist
169and
170.Fa eventlist .
171.Pp
172The
173.Fn EV_SET
174macro is provided for ease of initializing a
175kevent structure.
176.Pp
177The
178.Va kevent
179structure is defined as:
180.Bd -literal
181struct kevent {
182	uintptr_t  ident;	/* identifier for this event */
183	short	  filter;	/* filter for event */
184	u_short	  flags;	/* action flags for kqueue */
185	u_int	  fflags;	/* filter flag value */
186	int64_t   data;		/* filter data value */
187	void	  *udata;	/* opaque user data identifier */
188	uint64_t  ext[4];	/* extensions */
189};
190.Ed
191.Pp
192The fields of
193.Fa struct kevent
194are:
195.Bl -tag -width "Fa filter"
196.It Fa ident
197Value used to identify this event.
198The exact interpretation is determined by the attached filter,
199but often is a file descriptor.
200.It Fa filter
201Identifies the kernel filter used to process this event.
202The pre-defined
203system filters are described below.
204.It Fa flags
205Actions to perform on the event.
206.It Fa fflags
207Filter-specific flags.
208.It Fa data
209Filter-specific data value.
210.It Fa udata
211Opaque user-defined value passed through the kernel unchanged.
212.It Fa ext
213Extended data passed to and from kernel.
214The
215.Fa ext[0]
216and
217.Fa ext[1]
218members use is defined by the filter.
219If the filter does not use them, the members are copied unchanged.
220The
221.Fa ext[2]
222and
223.Fa ext[3]
224members are always passed through the kernel as-is,
225making additional context available to application.
226.El
227.Pp
228The
229.Va flags
230field can contain the following values:
231.Bl -tag -width EV_DISPATCH
232.It Dv EV_ADD
233Adds the event to the kqueue.
234Re-adding an existing event
235will modify the parameters of the original event, and not result
236in a duplicate entry.
237Adding an event automatically enables it,
238unless overridden by the EV_DISABLE flag.
239.It Dv EV_ENABLE
240Permit
241.Fn kevent
242to return the event if it is triggered.
243.It Dv EV_DISABLE
244Disable the event so
245.Fn kevent
246will not return it.
247The filter itself is not disabled.
248.It Dv EV_DISPATCH
249Disable the event source immediately after delivery of an event.
250See
251.Dv EV_DISABLE
252above.
253.It Dv EV_DELETE
254Removes the event from the kqueue.
255Events which are attached to
256file descriptors are automatically deleted on the last close of
257the descriptor.
258.It Dv EV_RECEIPT
259This flag is useful for making bulk changes to a kqueue without draining
260any pending events.
261When passed as input, it forces
262.Dv EV_ERROR
263to always be returned.
264When a filter is successfully added the
265.Va data
266field will be zero.
267Note that if this flag is encountered and there is no remaining space in
268.Fa eventlist
269to hold the
270.Dv EV_ERROR
271event, then subsequent changes will not get processed.
272.It Dv EV_ONESHOT
273Causes the event to return only the first occurrence of the filter
274being triggered.
275After the user retrieves the event from the kqueue,
276it is deleted.
277.It Dv EV_CLEAR
278After the event is retrieved by the user, its state is reset.
279This is useful for filters which report state transitions
280instead of the current state.
281Note that some filters may automatically
282set this flag internally.
283.It Dv EV_EOF
284Filters may set this flag to indicate filter-specific EOF condition.
285.It Dv EV_ERROR
286See
287.Sx RETURN VALUES
288below.
289.El
290.Pp
291The predefined system filters are listed below.
292Arguments may be passed to and from the filter via the
293.Va fflags
294and
295.Va data
296fields in the kevent structure.
297.Bl -tag -width "Dv EVFILT_PROCDESC"
298.It Dv EVFILT_READ
299Takes a descriptor as the identifier, and returns whenever
300there is data available to read.
301The behavior of the filter is slightly different depending
302on the descriptor type.
303.Bl -tag -width 2n
304.It Sockets
305Sockets which have previously been passed to
306.Xr listen 2
307return when there is an incoming connection pending.
308.Va data
309contains the size of the listen backlog.
310.Pp
311Other socket descriptors return when there is data to be read,
312subject to the
313.Dv SO_RCVLOWAT
314value of the socket buffer.
315This may be overridden with a per-filter low water mark at the
316time the filter is added by setting the
317.Dv NOTE_LOWAT
318flag in
319.Va fflags ,
320and specifying the new low water mark in
321.Va data .
322On return,
323.Va data
324contains the number of bytes of protocol data available to read.
325.Pp
326If the read direction of the socket has shutdown, then the filter
327also sets
328.Dv EV_EOF
329in
330.Va flags ,
331and returns the socket error (if any) in
332.Va fflags .
333It is possible for EOF to be returned (indicating the connection is gone)
334while there is still data pending in the socket buffer.
335.It Vnodes
336Returns when the file pointer is not at the end of file.
337.Va data
338contains the offset from current position to end of file,
339and may be negative.
340.Pp
341This behavior is different from
342.Xr poll 2 ,
343where read events are triggered for regular files unconditionally.
344This event can be triggered unconditionally by setting the
345.Dv NOTE_FILE_POLL
346flag in
347.Va fflags .
348.It "Fifos, Pipes"
349Returns when the there is data to read;
350.Va data
351contains the number of bytes available.
352.Pp
353When the last writer disconnects, the filter will set
354.Dv EV_EOF
355in
356.Va flags .
357This will be cleared by the filter when a new writer connects,
358at which point the
359filter will resume waiting for data to become available before
360returning.
361.It "BPF devices"
362Returns when the BPF buffer is full, the BPF timeout has expired, or
363when the BPF has
364.Dq immediate mode
365enabled and there is any data to read;
366.Va data
367contains the number of bytes available.
368.It Eventfds
369Returns when the counter is greater than 0;
370.Va data
371contains the counter value, which must be cast to
372.Vt uint64_t .
373.It Kqueues
374Returns when pending events are present on the queue;
375.Va data
376contains the number of events available.
377.El
378.It Dv EVFILT_WRITE
379Takes a descriptor as the identifier, and returns whenever
380it is possible to write to the descriptor.
381For sockets, pipes
382and fifos,
383.Va data
384will contain the amount of space remaining in the write buffer.
385The filter will set
386.Dv EV_EOF
387when the reader disconnects, and for the fifo case, this will be cleared
388when a new reader connects.
389Note that this filter is not supported for vnodes or BPF devices.
390.Pp
391For sockets, the low water mark and socket error handling is
392identical to the
393.Dv EVFILT_READ
394case.
395.Pp
396For eventfds,
397.Va data
398will contain the maximum value that can be added to the counter
399without blocking.
400.It Dv EVFILT_EMPTY
401Takes a descriptor as the identifier, and returns whenever
402there is no remaining data in the write buffer.
403.It Dv EVFILT_AIO
404Events for this filter are not registered with
405.Fn kevent
406directly but are registered via the
407.Va aio_sigevent
408member of an asynchronous I/O request when it is scheduled via an
409asynchronous I/O system call such as
410.Fn aio_read .
411The filter returns under the same conditions as
412.Fn aio_error .
413For more details on this filter see
414.Xr sigevent 3 and
415.Xr aio 4 .
416.It Dv EVFILT_VNODE
417Takes a file descriptor as the identifier and the events to watch for in
418.Va fflags ,
419and returns when one or more of the requested events occurs on the descriptor.
420The events to monitor are:
421.Bl -tag -width "Dv NOTE_CLOSE_WRITE"
422.It Dv NOTE_ATTRIB
423The file referenced by the descriptor had its attributes changed.
424.It Dv NOTE_CLOSE
425A file descriptor referencing the monitored file, was closed.
426The closed file descriptor did not have write access.
427.It Dv NOTE_CLOSE_WRITE
428A file descriptor referencing the monitored file, was closed.
429The closed file descriptor had write access.
430.Pp
431This note, as well as
432.Dv NOTE_CLOSE ,
433are not activated when files are closed forcibly by
434.Xr unmount 2 or
435.Xr revoke 2 .
436Instead,
437.Dv NOTE_REVOKE
438is sent for such events.
439.It Dv NOTE_DELETE
440The
441.Fn unlink
442system call was called on the file referenced by the descriptor.
443.It Dv NOTE_EXTEND
444For regular file, the file referenced by the descriptor was extended.
445.Pp
446For directory, reports that a directory entry was added or removed,
447as the result of rename operation.
448The
449.Dv NOTE_EXTEND
450event is not reported when a name is changed inside the directory.
451.It Dv NOTE_LINK
452The link count on the file changed.
453In particular, the
454.Dv NOTE_LINK
455event is reported if a subdirectory was created or deleted inside
456the directory referenced by the descriptor.
457.It Dv NOTE_OPEN
458The file referenced by the descriptor was opened.
459.It Dv NOTE_READ
460A read occurred on the file referenced by the descriptor.
461.It Dv NOTE_RENAME
462The file referenced by the descriptor was renamed.
463.It Dv NOTE_REVOKE
464Access to the file was revoked via
465.Xr revoke 2
466or the underlying file system was unmounted.
467.It Dv NOTE_WRITE
468A write occurred on the file referenced by the descriptor.
469.El
470.Pp
471On return,
472.Va fflags
473contains the events which triggered the filter.
474.It Dv EVFILT_PROC
475Takes the process ID to monitor as the identifier and the events to watch for
476in
477.Va fflags ,
478and returns when the process performs one or more of the requested events.
479If a process can normally see another process, it can attach an event to it.
480The events to monitor are:
481.Bl -tag -width "Dv NOTE_TRACKERR"
482.It Dv NOTE_EXIT
483The process has exited.
484The exit status will be stored in
485.Va data
486in the same format as the status returned by
487.Xr wait 2 .
488.It Dv NOTE_FORK
489The process has called
490.Fn fork .
491.It Dv NOTE_EXEC
492The process has executed a new process via
493.Xr execve 2
494or a similar call.
495.It Dv NOTE_TRACK
496Follow a process across
497.Fn fork
498calls.
499The parent process registers a new kevent to monitor the child process
500using the same
501.Va fflags
502as the original event.
503The child process will signal an event with
504.Dv NOTE_CHILD
505set in
506.Va fflags
507and the parent PID in
508.Va data .
509.Pp
510If the parent process fails to register a new kevent
511.Pq usually due to resource limitations ,
512it will signal an event with
513.Dv NOTE_TRACKERR
514set in
515.Va fflags ,
516and the child process will not signal a
517.Dv NOTE_CHILD
518event.
519.El
520.Pp
521On return,
522.Va fflags
523contains the events which triggered the filter.
524.It Dv EVFILT_PROCDESC
525Takes the process descriptor created by
526.Xr pdfork 2
527to monitor as the identifier and the events to watch for in
528.Va fflags ,
529and returns when the associated process performs one or more of the
530requested events.
531The events to monitor are:
532.Bl -tag -width "Dv NOTE_EXIT"
533.It Dv NOTE_EXIT
534The process has exited.
535The exit status will be stored in
536.Va data .
537.El
538.Pp
539On return,
540.Va fflags
541contains the events which triggered the filter.
542.It Dv EVFILT_SIGNAL
543Takes the signal number to monitor as the identifier and returns
544when the given signal is delivered to the process.
545This coexists with the
546.Fn signal
547and
548.Fn sigaction
549facilities, and has a lower precedence.
550The filter will record
551all attempts to deliver a signal to a process, even if the signal has
552been marked as
553.Dv SIG_IGN ,
554except for the
555.Dv SIGCHLD
556signal, which, if ignored, will not be recorded by the filter.
557Event notification happens after normal
558signal delivery processing.
559.Va data
560returns the number of times the signal has occurred since the last call to
561.Fn kevent .
562This filter automatically sets the
563.Dv EV_CLEAR
564flag internally.
565.It Dv EVFILT_TIMER
566Establishes an arbitrary timer identified by
567.Va ident .
568When adding a timer,
569.Va data
570specifies the moment to fire the timer (for
571.Dv NOTE_ABSTIME )
572or the timeout period.
573The timer will be periodic unless
574.Dv EV_ONESHOT
575or
576.Dv NOTE_ABSTIME
577is specified.
578On return,
579.Va data
580contains the number of times the timeout has expired since the last call to
581.Fn kevent .
582For non-monotonic timers, this filter automatically sets the
583.Dv EV_CLEAR
584flag internally.
585.Pp
586The filter accepts the following flags in the
587.Va fflags
588argument:
589.Bl -tag -width "Dv NOTE_MSECONDS"
590.It Dv NOTE_SECONDS
591.Va data
592is in seconds.
593.It Dv NOTE_MSECONDS
594.Va data
595is in milliseconds.
596.It Dv NOTE_USECONDS
597.Va data
598is in microseconds.
599.It Dv NOTE_NSECONDS
600.Va data
601is in nanoseconds.
602.It Dv NOTE_ABSTIME
603The specified expiration time is absolute.
604.El
605.Pp
606If
607.Va fflags
608is not set, the default is milliseconds.
609On return,
610.Va fflags
611contains the events which triggered the filter.
612.Pp
613Periodic timers with a specified timeout of 0 will be silently adjusted to
614timeout after 1 of the time units specified by the requested precision in
615.Va fflags .
616If an absolute time is specified that has already passed, then it is treated as
617if the current time were specified and the event will fire as soon as possible.
618.Pp
619If an existing timer is re-added, the existing timer will be
620effectively canceled (throwing away any undelivered record of previous
621timer expiration) and re-started using the new parameters contained in
622.Va data
623and
624.Va fflags .
625.Pp
626There is a system wide limit on the number of timers
627which is controlled by the
628.Va kern.kq_calloutmax
629sysctl.
630.It Dv EVFILT_USER
631Establishes a user event identified by
632.Va ident
633which is not associated with any kernel mechanism but is triggered by
634user level code.
635The lower 24 bits of the
636.Va fflags
637may be used for user defined flags and manipulated using the following:
638.Bl -tag -width "Dv NOTE_FFLAGSMASK"
639.It Dv NOTE_FFNOP
640Ignore the input
641.Va fflags .
642.It Dv NOTE_FFAND
643Bitwise AND
644.Va fflags .
645.It Dv NOTE_FFOR
646Bitwise OR
647.Va fflags .
648.It Dv NOTE_FFCOPY
649Copy
650.Va fflags .
651.It Dv NOTE_FFCTRLMASK
652Control mask for
653.Va fflags .
654.It Dv NOTE_FFLAGSMASK
655User defined flag mask for
656.Va fflags .
657.El
658.Pp
659A user event is triggered for output with the following:
660.Bl -tag -width "Dv NOTE_FFLAGSMASK"
661.It Dv NOTE_TRIGGER
662Cause the event to be triggered.
663.El
664.Pp
665On return,
666.Va fflags
667contains the users defined flags in the lower 24 bits.
668.El
669.Sh CANCELLATION BEHAVIOUR
670If
671.Fa nevents
672is non-zero, i.e., the function is potentially blocking, the call
673is a cancellation point.
674Otherwise, i.e., if
675.Fa nevents
676is zero, the call is not cancellable.
677Cancellation can only occur before any changes are made to the kqueue,
678or when the call was blocked and no changes to the queue were requested.
679.Sh RETURN VALUES
680The
681.Fn kqueue
682system call
683creates a new kernel event queue and returns a file descriptor.
684If there was an error creating the kernel event queue, a value of -1 is
685returned and errno set.
686.Pp
687The
688.Fn kevent
689system call
690returns the number of events placed in the
691.Fa eventlist ,
692up to the value given by
693.Fa nevents .
694If an error occurs while processing an element of the
695.Fa changelist
696and there is enough room in the
697.Fa eventlist ,
698then the event will be placed in the
699.Fa eventlist
700with
701.Dv EV_ERROR
702set in
703.Va flags
704and the system error in
705.Va data .
706Otherwise,
707.Dv -1
708will be returned, and
709.Dv errno
710will be set to indicate the error condition.
711If the time limit expires, then
712.Fn kevent
713returns 0.
714.Sh EXAMPLES
715.Bd -literal -compact
716#include <sys/event.h>
717#include <err.h>
718#include <fcntl.h>
719#include <stdio.h>
720#include <stdlib.h>
721#include <string.h>
722
723int
724main(int argc, char **argv)
725{
726    struct kevent event;    /* Event we want to monitor */
727    struct kevent tevent;   /* Event triggered */
728    int kq, fd, ret;
729
730    if (argc != 2)
731	err(EXIT_FAILURE, "Usage: %s path\en", argv[0]);
732    fd = open(argv[1], O_RDONLY);
733    if (fd == -1)
734	err(EXIT_FAILURE, "Failed to open '%s'", argv[1]);
735
736    /* Create kqueue. */
737    kq = kqueue();
738    if (kq == -1)
739	err(EXIT_FAILURE, "kqueue() failed");
740
741    /* Initialize kevent structure. */
742    EV_SET(&event, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE,
743	0, NULL);
744    /* Attach event to the kqueue. */
745    ret = kevent(kq, &event, 1, NULL, 0, NULL);
746    if (ret == -1)
747	err(EXIT_FAILURE, "kevent register");
748    if (event.flags & EV_ERROR)
749	errx(EXIT_FAILURE, "Event error: %s", strerror(event.data));
750
751    for (;;) {
752	/* Sleep until something happens. */
753	ret = kevent(kq, NULL, 0, &tevent, 1, NULL);
754	if (ret == -1) {
755	    err(EXIT_FAILURE, "kevent wait");
756	} else if (ret > 0) {
757	    printf("Something was written in '%s'\en", argv[1]);
758	}
759    }
760}
761.Ed
762.Sh ERRORS
763The
764.Fn kqueue
765system call fails if:
766.Bl -tag -width Er
767.It Bq Er ENOMEM
768The kernel failed to allocate enough memory for the kernel queue.
769.It Bq Er ENOMEM
770The
771.Dv RLIMIT_KQUEUES
772rlimit
773(see
774.Xr getrlimit 2 )
775for the current user would be exceeded.
776.It Bq Er EMFILE
777The per-process descriptor table is full.
778.It Bq Er ENFILE
779The system file table is full.
780.El
781.Pp
782The
783.Fn kevent
784system call fails if:
785.Bl -tag -width Er
786.It Bq Er EACCES
787The process does not have permission to register a filter.
788.It Bq Er EFAULT
789There was an error reading or writing the
790.Va kevent
791structure.
792.It Bq Er EBADF
793The specified descriptor is invalid.
794.It Bq Er EINTR
795A signal was delivered before the timeout expired and before any
796events were placed on the kqueue for return.
797.It Bq Er EINTR
798A cancellation request was delivered to the thread, but not yet handled.
799.It Bq Er EINVAL
800The specified time limit or filter is invalid.
801.It Bq Er EINVAL
802The specified length of the event or change lists is negative.
803.It Bq Er ENOENT
804The event could not be found to be modified or deleted.
805.It Bq Er ENOMEM
806No memory was available to register the event
807or, in the special case of a timer, the maximum number of
808timers has been exceeded.
809This maximum is configurable via the
810.Va kern.kq_calloutmax
811sysctl.
812.It Bq Er ESRCH
813The specified process to attach to does not exist.
814.El
815.Pp
816When
817.Fn kevent
818call fails with
819.Er EINTR
820error, all changes in the
821.Fa changelist
822have been applied.
823.Sh SEE ALSO
824.Xr aio_error 2 ,
825.Xr aio_read 2 ,
826.Xr aio_return 2 ,
827.Xr poll 2 ,
828.Xr read 2 ,
829.Xr select 2 ,
830.Xr sigaction 2 ,
831.Xr write 2 ,
832.Xr pthread_setcancelstate 3 ,
833.Xr signal 3
834.Rs
835.%A Jonathan Lemon
836.%T "Kqueue: A Generic and Scalable Event Notification Facility"
837.%I USENIX Association
838.%B Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference
839.%D June 25-30, 2001
840.\".http://www.usenix.org/event/usenix01/freenix01/full_papers/lemon/lemon.pdf
841.Re
842.Sh HISTORY
843The
844.Fn kqueue
845and
846.Fn kevent
847system calls first appeared in
848.Fx 4.1 .
849.Sh AUTHORS
850The
851.Fn kqueue
852system and this manual page were written by
853.An Jonathan Lemon Aq Mt jlemon@FreeBSD.org .
854.Sh BUGS
855.Pp
856In versions older than
857.Fx 12.0 ,
858.In sys/event.h
859failed to parse without including
860.In sys/types.h
861manually.
862