Page MenuHomeFreeBSD

D39271.id119466.diff
No OneTemporary

D39271.id119466.diff

diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -430,6 +430,7 @@
jail.2 jail_set.2
MLINKS+=kldunload.2 kldunloadf.2
MLINKS+=kqueue.2 kevent.2 \
+ kqueue.2 kqueue1.2 \
kqueue.2 EV_SET.3
MLINKS+=link.2 linkat.2
MLINKS+=madvise.2 posix_madvise.2
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -419,6 +419,7 @@
FBSD_1.7 {
_Fork;
fspacectl;
+ kqueue1;
swapoff;
};
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 14, 2022
+.Dd March 26, 2023
.Dt KQUEUE 2
.Os
.Sh NAME
@@ -38,6 +38,8 @@
.Ft int
.Fn kqueue "void"
.Ft int
+.Fn kqueue1 "u_int flags"
+.Ft int
.Fo kevent
.Fa "int kq"
.Fa "const struct kevent *changelist"
@@ -90,6 +92,22 @@
which will allow sharing of the kqueue between two processes.
.Pp
The
+.Fn kqueue1
+system call also creates a new kernel event queue, and additionally takes
+the
+.Fa flags
+argument, which is logically or-ed by the following flags:
+.Bl -tag -width "KQ1_CLOEXEC"
+.It Fa KQ1_CLOEXEC
+The returned file descriptor is automatically closed on
+.Xr execve 2
+.El
+The
+.Ql fd = kqueue()
+call is equivalent to
+.Ql fd = kqueue1(0) .
+.Pp
+The
.Fn kevent
system call
is used to register events with the queue, and return any pending
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1057,6 +1057,19 @@
return (kern_kqueue(td, 0, NULL));
}
+int
+sys_kqueue1(struct thread *td, struct kqueue1_args *uap)
+{
+ int flags;
+
+ if ((uap->flags & ~(KQ1_CLOEXEC)) != 0)
+ return (EINVAL);
+ flags = 0;
+ if ((uap->flags & KQ1_CLOEXEC) != 0)
+ flags |= O_CLOEXEC;
+ return (kern_kqueue(td, flags, NULL));
+}
+
static void
kqueue_init(struct kqueue *kq)
{
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -3306,5 +3306,10 @@
u_int flags,
);
}
+583 AUE_KQUEUE STD|CAPENABLED {
+ int kqueue1(
+ u_int flags
+ );
+ }
; vim: syntax=off
diff --git a/sys/sys/event.h b/sys/sys/event.h
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -218,6 +218,9 @@
#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */
#define NOTE_ABSTIME 0x00000010 /* timeout is absolute */
+/* Flags for kqueue1(2) */
+#define KQ1_CLOEXEC 0x00000001 /* close on exec */
+
struct knote;
SLIST_HEAD(klist, knote);
struct kqueue;
@@ -358,6 +361,7 @@
__BEGIN_DECLS
int kqueue(void);
+int kqueue1(u_int flags);
int kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout);

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 18, 12:09 AM (13 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29862128
Default Alt Text
D39271.id119466.diff (2 KB)

Event Timeline