Author: markj
Date: Mon May 11 15:17:57 2020
New Revision: 360895
URL: https://svnweb.freebsd.org/changeset/base/360895

Log:
  MFC r360378:
  Avoid returning POLLIN if the pipe descriptor is not open for reading.

Modified:
  stable/12/sys/kern/sys_pipe.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/sys_pipe.c
==============================================================================
--- stable/12/sys/kern/sys_pipe.c       Mon May 11 08:40:33 2020        
(r360894)
+++ stable/12/sys/kern/sys_pipe.c       Mon May 11 15:17:57 2020        
(r360895)
@@ -1432,7 +1432,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;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to