Avoid returning POLLIN if the pipe descriptor is not open for reading.

Submitted by:	Jan Kokemüller <jan.kokemueller@gmail.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24528
This commit is contained in:
Mark Johnston 2020-04-27 15:58:55 +00:00
parent decb087cc2
commit 9ab4355732

View File

@ -1430,7 +1430,8 @@ pipe_poll(struct file *fp, int events, struct ucred *active_cred,
if ((events & POLLINIGNEOF) == 0) {
if (rpipe->pipe_state & PIPE_EOF) {
revents |= (events & (POLLIN | POLLRDNORM));
if (fp->f_flag & FREAD)
revents |= (events & (POLLIN | POLLRDNORM));
if (wpipe->pipe_present != PIPE_ACTIVE ||
(wpipe->pipe_state & PIPE_EOF))
revents |= POLLHUP;