xref: /netbsd/share/man/man9/knote.9 (revision c4a72b64)
1.\"	$NetBSD: knote.9,v 1.5 2002/10/23 09:35:26 jdolecek Exp $
2.\"
3.\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This documentation is derived from text contributed by
7.\" Luke Mewburn.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd October 23, 2002
38.Dt KNOTE 9
39.Os
40.Sh NAME
41.Nm knote ,
42.Nm KNOTE
43.Nd raise kernel event
44.Sh SYNOPSIS
45.Fd #include \*[Lt]sys/event.h\*[Gt]
46.Ft void
47.Fn knote "struct klist *list" "long hint"
48.Fn KNOTE "struct klist *list" "long hint"
49.Sh DESCRIPTION
50The
51.Fn knote
52function provides a hook into the kqueue kernel event notification
53mechanism to allow sections of the kernel to raise a kernel event
54in the form of a
55.Sq knote ,
56which is a
57.Fa struct knote
58as defined in
59.Aq Pa sys/event.h .
60.Pp
61.Fn knote
62takes a singly linked
63.Fa list
64of knotes, along with with a
65.Fa hint
66(which is passed to the appropriate filter routine).
67.Fn knote
68then walks the
69.Fa list
70making calls to the filter routine for each knote.
71As each knote contains a reference to the data structure that it is
72attached to, the filter may choose to examine the data structure in
73deciding whether an event should be reported.
74The
75.Fa hint
76is used to pass in additional information, which may not be present in
77the data structure that the filter examines.
78.Pp
79If the filter decides that the event should be returned, it returns a
80non-zero value and
81.Fn knote
82links the knote onto the tail end of the active list in the
83corresponding kqueue for the application to retrieve.
84If the knote is already on the active list, no action is taken, but the
85call to the filter occurs in order to provide an opportunity for the
86filter to record the activity.
87.Pp
88.Fn KNOTE
89is a macro that calls
90.Fn knote list hint
91if
92.Fa list
93is not empty.
94.\" .Sh ERRORS
95.Sh SEE ALSO
96.Xr kqueue 2 ,
97.Xr kfilter_register 9
98.Sh HISTORY
99The
100.Fn knote
101and
102.Fn KNOTE
103functions first appeared in
104.Fx 4.1 ,
105and then in
106.\" NEXTRELEASE
107.Nx 2.0 .
108.Sh AUTHORS
109The
110.Fn kqueue
111system was written by
112.An Jonathan Lemon Aq jlemon@FreeBSD.org .
113