-/* $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 $ */
/*
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];
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);
-/* $OpenBSD: fifo_vnops.c,v 1.46 2015/05/05 20:14:10 millert Exp $ */
+/* $OpenBSD: fifo_vnops.c,v 1.47 2015/05/10 22:35:39 millert Exp $ */
/* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */
/*
int revents = 0;
/*
- * Just return if there are no supported events specified,
* FIFOs don't support out-of-band or high priority data.
*/
if (ap->a_fflag & FREAD)
events |= ap->a_events & (POLLIN | POLLRDNORM);
if (ap->a_fflag & FWRITE)
events |= ap->a_events & (POLLOUT | POLLWRNORM);
- if (events == 0)
- return (0);
if (events & (POLLIN | POLLRDNORM)) {
if (soreadable(rso))
revents |= events & (POLLIN | POLLRDNORM);
}
/* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */
- if (rso->so_state & SS_ISDISCONNECTED) {
+ if ((rso->so_state & SS_ISDISCONNECTED) && !(ap->a_events & POLLNOHUP)) {
revents |= POLLHUP;
} else if (events & (POLLOUT | POLLWRNORM)) {
if (sowriteable(wso))
revents |= events & (POLLOUT | POLLWRNORM);
}
if (revents == 0) {
+ /* We want to return POLLHUP even if no valid events set. */
+ if (events == 0 && !(ap->a_events & POLLNOHUP))
+ events = POLLIN;
if (events & (POLLIN | POLLRDNORM)) {
selrecord(ap->a_p, &rso->so_rcv.sb_sel);
rso->so_rcv.sb_flagsintr |= SB_SEL;
-/* $OpenBSD: poll.h,v 1.13 2013/04/29 18:35:07 guenther Exp $ */
+/* $OpenBSD: poll.h,v 1.14 2015/05/10 22:35:38 millert Exp $ */
/*
* Copyright (c) 1996 Theo de Raadt
#define POLLWRNORM POLLOUT
#define POLLRDBAND 0x0080
#define POLLWRBAND 0x0100
+#ifdef _KERNEL
+#define POLLNOHUP 0x1000 /* internal use only */
+#endif
#define INFTIM (-1)