summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_generic.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-05-10 22:35:38 +0000
committermillert <millert@openbsd.org>2015-05-10 22:35:38 +0000
commitb7b44fe5796e416f560eb15867dc757db11a47d6 (patch)
tree43200ee9dc037d16b8ec01bf207e4f187da941f0 /sys/kern/sys_generic.c
parentAdd _bfd_ar_spacepadll() for formatting long long values in archive headers. (diff)
downloadwireguard-openbsd-b7b44fe5796e416f560eb15867dc757db11a47d6.tar.xz
wireguard-openbsd-b7b44fe5796e416f560eb15867dc757db11a47d6.zip
Set POLLHUP even if no valid events were specified as per POSIX.
Since we use the poll backend for select(2), care must be taken not to set the fd's bit in writefds in this case. A kernel-only flag, POLLNOHUP, is used by selscan() to tell the poll backend not to return POLLHUP on EOF. This is currently only used by fifo_poll(). The fifofs regress now passes. OK guenther@
Diffstat (limited to 'sys/kern/sys_generic.c')
-rw-r--r--sys/kern/sys_generic.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index 57b1813f080..cefcf9f7a5f 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.97 2015/04/30 09:20:51 mpi Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.98 2015/05/10 22:35:38 millert Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -712,7 +712,7 @@ selscan(struct proc *p, fd_set *ibits, fd_set *obits, int nfd, int ni,
fd_mask bits;
struct file *fp;
int n = 0;
- static const int flag[3] = { POLLIN, POLLOUT, POLLPRI };
+ static const int flag[3] = { POLLIN, POLLOUT|POLLNOHUP, POLLPRI };
for (msk = 0; msk < 3; msk++) {
fd_set *pibits = (fd_set *)&cibits[msk*ni];
@@ -940,8 +940,10 @@ doppoll(struct proc *p, struct pollfd *fds, u_int nfds,
if ((error = copyin(fds, pl, sz)) != 0)
goto bad;
- for (i = 0; i < nfds; i++)
+ for (i = 0; i < nfds; i++) {
+ pl[i].events &= ~POLLNOHUP;
pl[i].revents = 0;
+ }
if (tsp != NULL) {
getnanouptime(&rts);