Add kqueue1() syscall

It takes the flags argument.  Immediate use is to provide the KQUEUE_CLOEXEC
flag for kqueue(2).

Reviewed by:	emaste, jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39271
This commit is contained in:
Konstantin Belousov 2023-03-26 01:39:02 +02:00
parent ac6b2b4344
commit 61194e9852
3 changed files with 21 additions and 0 deletions

View File

@ -1057,6 +1057,19 @@ sys_kqueue(struct thread *td, struct kqueue_args *uap)
return (kern_kqueue(td, 0, NULL));
}
int
sys_kqueue1(struct thread *td, struct kqueue1_args *uap)
{
int flags;
if ((uap->flags & ~(KQUEUE_CLOEXEC)) != 0)
return (EINVAL);
flags = 0;
if ((uap->flags & KQUEUE_CLOEXEC) != 0)
flags |= O_CLOEXEC;
return (kern_kqueue(td, flags, NULL));
}
static void
kqueue_init(struct kqueue *kq)
{

View File

@ -3306,5 +3306,10 @@
u_int flags,
);
}
583 AUE_KQUEUE STD|CAPENABLED {
int kqueue1(
u_int flags
);
}
; vim: syntax=off

View File

@ -218,6 +218,9 @@ struct freebsd11_kevent32 {
#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */
#define NOTE_ABSTIME 0x00000010 /* timeout is absolute */
/* Flags for kqueue1(2) */
#define KQUEUE_CLOEXEC 0x00000001 /* close on exec */
struct knote;
SLIST_HEAD(klist, knote);
struct kqueue;