I've taken a stab at improving kqueue.2 formatting.
Most of the changes are markup fixes.
I used ".Dv NULL" over plain "null" in accordance with
lib/libc/stdlib/malloc.3 rev. 1.113.
I also added a note to the HISTORY section that kqueue()/kevent() have
been available in OpenBSD since 2.9;
the wording matches growfs(8).
I'm not sure how to handle the undocumented EPERM that is returned if a
pledge(2) does not include "proc" when an attempt is made to attach to a
process with EVFILT_PROC.
It does feel somewhat non-obvious, but is noted in neither pledge(2) nor
kqueue(2).
Index: lib/libc/sys/kqueue.2
===
RCS file: /cvs/src/lib/libc/sys/kqueue.2,v
retrieving revision 1.37
diff -u -p -u -p -r1.37 kqueue.2
--- lib/libc/sys/kqueue.2 13 Jan 2018 17:13:12 - 1.37
+++ lib/libc/sys/kqueue.2 2 May 2019 13:28:27 -
@@ -67,9 +67,9 @@ is not returned.
Multiple events which trigger the filter do not result in multiple
kevents being placed on the kqueue; instead, the filter will aggregate
the events into a single
-.Li struct kevent .
+.Vt struct kevent .
Calling
-.Fn close
+.Xr close 2
on a file descriptor will remove any kevents that reference the descriptor.
.Pp
.Fn kqueue
@@ -83,8 +83,8 @@ is used to register events with the queu
events to the user.
.Fa changelist
is a pointer to an array of
-.Va kevent
-structures, as defined in
+.Vt struct kevent ,
+as defined in
.In sys/event.h .
All changes contained in the
.Fa changelist
@@ -107,19 +107,23 @@ specified unlike
.Xr select 2 .
If
.Fa timeout
-is a non-null pointer, it specifies a maximum interval to wait
+is not
+.Dv NULL ,
+it specifies a maximum interval to wait
for an event, which will be interpreted as a
-.Li struct timespec .
+.Vt struct timespec .
If
.Fa timeout
-is a null pointer,
+is
+.Dv NULL ,
.Fn kevent
waits indefinitely.
To effect a poll, the
.Fa timeout
-argument should be non-null, pointing to a zero-valued
-.Va timespec
-structure.
+argument should not be
+.Dv NULL ,
+pointing to a zero-valued
+.Vt struct timespec .
The same array may be used for the
.Fa changelist
and
@@ -130,7 +134,7 @@ is a macro which is provided for ease of
kevent structure.
.Pp
The
-.Va kevent
+.Vt kevent
structure is defined as:
.Bd -literal
struct kevent {
@@ -144,28 +148,28 @@ struct kevent {
.Ed
.Pp
The fields of
-.Li struct kevent
+.Vt struct kevent
are:
.Bl -tag -width XXXfilter
-.It ident
+.It Fa ident
Value used to identify this event.
The exact interpretation is determined by the attached filter,
but often is a file descriptor.
-.It filter
+.It Fa filter
Identifies the kernel filter used to process this event.
The pre-defined system filters are described below.
-.It flags
+.It Fa flags
Actions to perform on the event.
-.It fflags
+.It Fa fflags
Filter-specific flags.
-.It data
+.It Fa data
Filter-specific data value.
-.It udata
+.It Fa udata
Opaque user-defined value passed through the kernel unchanged.
.El
.Pp
The
-.Va flags
+.Fa flags
field can contain the following values:
.Bl -tag -width XXXEV_ONESHOT
.It Dv EV_ADD
@@ -200,7 +204,7 @@ to return with
.Dv EV_ERROR
set without draining any pending events after updating events in the kqueue.
When a filter is successfully added the
-.Va data
+.Fa data
field will be zero.
This flag is useful for making bulk changes to a kqueue.
.It Dv EV_ONESHOT
@@ -222,9 +226,9 @@ below.
.Pp
The predefined system filters are listed below.
Arguments may be passed to and from the filter via the
-.Va fflags
+.Fa fflags
and
-.Va data
+.Fa data
fields in the kevent structure.
.Bl -tag -width EVFILT_SIGNAL
.It Dv EVFILT_READ
@@ -235,9 +239,9 @@ on the descriptor type.
.Bl -tag -width 2n
.It Sockets
Sockets which have previously been passed to
-.Fn listen
+.Xr listen 2
return when there is an incoming connection pending.
-.Va data
+.Fa data
contains the size of the listen backlog.
.Pp
Other socket descriptors return when there is data to be read,
@@ -248,47 +252,47 @@ This may be overridden with a per-filter
time the filter is added by setting the
.Dv NOTE_LOWAT
flag in
-.Va fflags ,
+.Fa fflags ,
and specifying the new low water mark in
-.Va data .
+.Fa data .
On return,
-.Va data
+.Fa data
contains the number of bytes in the socket buffer.
.Pp
If the read direction of the socket has shutdown, then the filter
also sets
.Dv EV_EOF
in
-.Va flags ,
+.Fa flags ,
and returns the socket error (if any) in
-.Va fflags .
+.Fa fflags .
It is possible for EOF to be returned (indicating the connection is gone)
while there is still data pending in the socket buffer.
.It Vnodes
Returns when the file pointer is not at the end of file.
-.Va data
+.Fa data
contains the offset from current position to end of file,
and may be negative.
If
.Dv NOTE_EOF
is set in
-.Va fflags ,
+.Fa fflags ,
.Fn kevent
will also return when the file pointer is at the end of file.
The end of file