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 <[email protected]>
  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;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to