-/* $OpenBSD: kern_event.c,v 1.197 2023/08/13 08:29:28 visa Exp $ */
+/* $OpenBSD: kern_event.c,v 1.198 2023/08/20 15:13:43 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
#define KLIST_ASSERT_LOCKED(kl) ((void)(kl))
#endif
+int dokqueue(struct proc *, int, register_t *);
struct kqueue *kqueue_alloc(struct filedesc *);
void kqueue_terminate(struct proc *p, struct kqueue *);
void KQREF(struct kqueue *);
}
int
-sys_kqueue(struct proc *p, void *v, register_t *retval)
+dokqueue(struct proc *p, int flags, register_t *retval)
{
struct filedesc *fdp = p->p_fd;
struct kqueue *kq;
struct file *fp;
- int fd, error;
+ int cloexec, error, fd;
+
+ cloexec = (flags & O_CLOEXEC) ? UF_EXCLOSE : 0;
kq = kqueue_alloc(fdp);
error = falloc(p, &fp, &fd);
if (error)
goto out;
- fp->f_flag = FREAD | FWRITE;
+ fp->f_flag = FREAD | FWRITE | (flags & FNONBLOCK);
fp->f_type = DTYPE_KQUEUE;
fp->f_ops = &kqueueops;
fp->f_data = kq;
*retval = fd;
LIST_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_next);
kq = NULL;
- fdinsert(fdp, fd, 0, fp);
+ fdinsert(fdp, fd, cloexec, fp);
FRELE(fp, p);
out:
fdpunlock(fdp);
return (error);
}
+int
+sys_kqueue(struct proc *p, void *v, register_t *retval)
+{
+ return (dokqueue(p, 0, retval));
+}
+
+int
+sys_kqueue1(struct proc *p, void *v, register_t *retval)
+{
+ struct sys_kqueue1_args /* {
+ syscallarg(int) flags;
+ } */ *uap = v;
+
+ if (SCARG(uap, flags) & ~(O_CLOEXEC | FNONBLOCK))
+ return (EINVAL);
+ return (dokqueue(p, SCARG(uap, flags), retval));
+}
+
int
sys_kevent(struct proc *p, void *v, register_t *retval)
{
-/* $OpenBSD: kern_pledge.c,v 1.306 2023/06/02 17:44:29 cheloha Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.307 2023/08/20 15:13:43 visa Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
[SYS_ppoll] = PLEDGE_STDIO,
[SYS_kevent] = PLEDGE_STDIO,
[SYS_kqueue] = PLEDGE_STDIO,
+ [SYS_kqueue1] = PLEDGE_STDIO,
[SYS_select] = PLEDGE_STDIO,
[SYS_pselect] = PLEDGE_STDIO,
-; $OpenBSD: syscalls.master,v 1.249 2023/07/24 19:32:23 miod Exp $
+; $OpenBSD: syscalls.master,v 1.250 2023/08/20 15:13:43 visa Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
267 OBSOL pad_preadv
268 OBSOL pad_pwritev
269 STD NOLOCK { int sys_kqueue(void); }
-270 OBSOL t32_kevent
+270 STD NOLOCK { int sys_kqueue1(int flags); }
271 STD { int sys_mlockall(int flags); }
272 STD { int sys_munlockall(void); }
273 UNIMPL sys_getpeereid
-/* $OpenBSD: event.h,v 1.70 2023/08/13 08:29:28 visa Exp $ */
+/* $OpenBSD: event.h,v 1.71 2023/08/20 15:13:43 visa Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
__BEGIN_DECLS
int kqueue(void);
+int kqueue1(int flags);
int kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents,
const struct timespec *timeout);