Deleted Added
full compact
kqueue.2 (275900) kqueue.2 (281454)
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.

--- 8 unchanged lines hidden (view full) ---

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.\"
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.

--- 8 unchanged lines hidden (view full) ---

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.\" $FreeBSD: stable/10/lib/libc/sys/kqueue.2 275900 2014-12-18 11:36:14Z kib $
25.\" $FreeBSD: stable/10/lib/libc/sys/kqueue.2 281454 2015-04-12 06:52:43Z kib $
26.\"
26.\"
27.Dd July 18, 2014
27.Dd March 29, 2015
28.Dt KQUEUE 2
29.Os
30.Sh NAME
31.Nm kqueue ,
32.Nm kevent
33.Nd kernel event notification mechanism
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In sys/types.h
38.In sys/event.h
39.In sys/time.h
40.Ft int
41.Fn kqueue "void"
42.Ft int
43.Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout"
28.Dt KQUEUE 2
29.Os
30.Sh NAME
31.Nm kqueue ,
32.Nm kevent
33.Nd kernel event notification mechanism
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In sys/types.h
38.In sys/event.h
39.In sys/time.h
40.Ft int
41.Fn kqueue "void"
42.Ft int
43.Fn kevent "int kq" "const struct kevent *changelist" "int nchanges" "struct kevent *eventlist" "int nevents" "const struct timespec *timeout"
44.Fn EV_SET "&kev" ident filter flags fflags data udata
44.Fn EV_SET "kev" ident filter flags fflags data udata
45.Sh DESCRIPTION
46The
47.Fn kqueue
48system call
49provides a generic method of notifying the user when an event
50happens or a condition holds, based on the results of small
51pieces of kernel code termed filters.
52A kevent is identified by the (ident, filter) pair; there may only

--- 474 unchanged lines hidden (view full) ---

527.It Dv NOTE_TRIGGER
528Cause the event to be triggered.
529.El
530.Pp
531On return,
532.Va fflags
533contains the users defined flags in the lower 24 bits.
534.El
45.Sh DESCRIPTION
46The
47.Fn kqueue
48system call
49provides a generic method of notifying the user when an event
50happens or a condition holds, based on the results of small
51pieces of kernel code termed filters.
52A kevent is identified by the (ident, filter) pair; there may only

--- 474 unchanged lines hidden (view full) ---

527.It Dv NOTE_TRIGGER
528Cause the event to be triggered.
529.El
530.Pp
531On return,
532.Va fflags
533contains the users defined flags in the lower 24 bits.
534.El
535.Sh CANCELLATION BEHAVIOUR
536If
537.Fa nevents
538is non-zero, i.e. the function is potentially blocking, the call
539is a cancellation point.
540Otherwise, i.e. if
541.Fa nevents
542is zero, the call is not cancellable.
543Cancellation can only occur before any changes are made to the kqueue,
544or when the call was blocked and no changes to the queue were requested.
535.Sh RETURN VALUES
536The
537.Fn kqueue
538system call
539creates a new kernel event queue and returns a file descriptor.
540If there was an error creating the kernel event queue, a value of -1 is
541returned and errno set.
542.Pp

--- 47 unchanged lines hidden (view full) ---

590There was an error reading or writing the
591.Va kevent
592structure.
593.It Bq Er EBADF
594The specified descriptor is invalid.
595.It Bq Er EINTR
596A signal was delivered before the timeout expired and before any
597events were placed on the kqueue for return.
545.Sh RETURN VALUES
546The
547.Fn kqueue
548system call
549creates a new kernel event queue and returns a file descriptor.
550If there was an error creating the kernel event queue, a value of -1 is
551returned and errno set.
552.Pp

--- 47 unchanged lines hidden (view full) ---

600There was an error reading or writing the
601.Va kevent
602structure.
603.It Bq Er EBADF
604The specified descriptor is invalid.
605.It Bq Er EINTR
606A signal was delivered before the timeout expired and before any
607events were placed on the kqueue for return.
608.It Bq Er EINTR
609A cancellation request was delivered to the thread, but not yet handled.
598.It Bq Er EINVAL
599The specified time limit or filter is invalid.
600.It Bq Er ENOENT
601The event could not be found to be modified or deleted.
602.It Bq Er ENOMEM
603No memory was available to register the event
604or, in the special case of a timer, the maximum number of
605timers has been exceeded.
606This maximum is configurable via the
607.Va kern.kq_calloutmax
608sysctl.
609.It Bq Er ESRCH
610The specified process to attach to does not exist.
611.El
610.It Bq Er EINVAL
611The specified time limit or filter is invalid.
612.It Bq Er ENOENT
613The event could not be found to be modified or deleted.
614.It Bq Er ENOMEM
615No memory was available to register the event
616or, in the special case of a timer, the maximum number of
617timers has been exceeded.
618This maximum is configurable via the
619.Va kern.kq_calloutmax
620sysctl.
621.It Bq Er ESRCH
622The specified process to attach to does not exist.
623.El
624.Pp
625When
626.Fn kevent
627call fails with
628.Er EINTR
629error, all changes in the
630.Fa changelist
631have been applied.
612.Sh SEE ALSO
613.Xr aio_error 2 ,
614.Xr aio_read 2 ,
615.Xr aio_return 2 ,
616.Xr poll 2 ,
617.Xr read 2 ,
618.Xr select 2 ,
619.Xr sigaction 2 ,
620.Xr write 2 ,
632.Sh SEE ALSO
633.Xr aio_error 2 ,
634.Xr aio_read 2 ,
635.Xr aio_return 2 ,
636.Xr poll 2 ,
637.Xr read 2 ,
638.Xr select 2 ,
639.Xr sigaction 2 ,
640.Xr write 2 ,
641.Xr pthread_setcancelstate 3 ,
621.Xr signal 3
622.Sh HISTORY
623The
624.Fn kqueue
625and
626.Fn kevent
627system calls first appeared in
628.Fx 4.1 .
629.Sh AUTHORS
630The
631.Fn kqueue
632system and this manual page were written by
633.An Jonathan Lemon Aq jlemon@FreeBSD.org .
634.Sh BUGS
635The
636.Fa timeout
637value is limited to 24 hours; longer timeouts will be silently
638reinterpreted as 24 hours.
642.Xr signal 3
643.Sh HISTORY
644The
645.Fn kqueue
646and
647.Fn kevent
648system calls first appeared in
649.Fx 4.1 .
650.Sh AUTHORS
651The
652.Fn kqueue
653system and this manual page were written by
654.An Jonathan Lemon Aq jlemon@FreeBSD.org .
655.Sh BUGS
656The
657.Fa timeout
658value is limited to 24 hours; longer timeouts will be silently
659reinterpreted as 24 hours.