svn commit: r360378 - head/sys/kern

Mark Johnston markj at FreeBSD.org
Mon Apr 27 15:58:56 UTC 2020


Author: markj
Date: Mon Apr 27 15:58:55 2020
New Revision: 360378
URL: https://svnweb.freebsd.org/changeset/base/360378

Log:
  Avoid returning POLLIN if the pipe descriptor is not open for reading.
  
  Submitted by:	Jan Kokemüller <jan.kokemueller at gmail.com>
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D24528

Modified:
  head/sys/kern/sys_pipe.c

Modified: head/sys/kern/sys_pipe.c
==============================================================================
--- head/sys/kern/sys_pipe.c	Mon Apr 27 14:35:39 2020	(r360377)
+++ head/sys/kern/sys_pipe.c	Mon Apr 27 15:58:55 2020	(r360378)
@@ -1430,7 +1430,8 @@ pipe_poll(struct file *fp, int events, struct ucred *a
 
 	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;


More information about the svn-src-head mailing list