diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2013-09-28 15:21:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2013-09-28 15:21:56 +0000 |
commit | 0e755d38de07512d6921183315aea87c97e7fbee (patch) | |
tree | d90615ff7ffbeb18df78afa16652cd3da5b56e7c /sys/kern/sys_socket.c | |
parent | 493141d5de8b4ad32b33a8f64a2a28de3e6adaa0 (diff) |
poll(2) on a socket should set POLLHUP on EOF. This makes the
behavior of socketpair(2) match that of pipe(2) when the other end
is closed. OK guenther@
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r-- | sys/kern/sys_socket.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 9958e1f50cd..67fb49c4ea4 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_socket.c,v 1.16 2013/04/05 08:25:30 tedu Exp $ */ +/* $OpenBSD: sys_socket.c,v 1.17 2013/09/28 15:21:55 millert Exp $ */ /* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */ /* @@ -139,7 +139,10 @@ soo_poll(struct file *fp, int events, struct proc *p) if (soreadable(so)) revents |= events & (POLLIN | POLLRDNORM); } - if (events & (POLLOUT | POLLWRNORM)) { + /* NOTE: POLLHUP and POLLOUT/POLLWRNORM are mutually exclusive */ + if (so->so_state & SS_ISDISCONNECTED) { + revents |= POLLHUP; + } else if (events & (POLLOUT | POLLWRNORM)) { if (sowriteable(so)) revents |= events & (POLLOUT | POLLWRNORM); } |