From owner-freebsd-bugs Fri Feb 18 19:50: 5 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id ECDF837BB49 for ; Fri, 18 Feb 2000 19:50:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id TAA54038; Fri, 18 Feb 2000 19:50:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from limmax.k2r.org (limmax.k2r.org [210.160.188.69]) by hub.freebsd.org (Postfix) with SMTP id E9E7537BB52 for ; Fri, 18 Feb 2000 19:49:39 -0800 (PST) (envelope-from kenji@k2r.org) Received: (qmail 75316 invoked by uid 1000); 19 Feb 2000 03:49:55 -0000 Message-Id: <20000219034955.75315.qmail@k2r.org> Date: 19 Feb 2000 03:49:55 -0000 From: kenji.rikitake@acm.org Reply-To: kenji.rikitake@acm.org To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/16816: vop_stdpoll() in /sys/kern/vfs_default.c does not handle POLLIN/POLLOUT flags Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 16816 >Category: kern >Synopsis: vop_stdpoll() in /sys/kern/vfs_default.c does not handle POLLIN/POLLOUT >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Feb 18 19:50:01 PST 2000 >Closed-Date: >Last-Modified: >Originator: Kenji Rikitake >Release: FreeBSD 3.4-RELEASE i386 >Organization: K2 Research >Environment: FreeBSD 3.4-RELEASE >Description: When monitoring stdin using poll() with event POLLIN, it works when stdin is redirected to a pipe, but it does not when stdin is redirected to a local system file (vfs). I think this behavior is weird because POLLIN seems to work for all the other devices/socket/pipe/file-systems buf vfs. >How-To-Repeat: cc -o poll-sample poll-sample.c echo "127.0.0.1" > foo cat ./foo | ./poll-sample retval = 1, revents=17 ./poll-sample < ~/.foo retval = 0, revents=0 (after waiting 10 seconds) when using POLLRDNORM for the value of x[0].events, the file redirection works as: retval = 1, revents=64 /* poll-sample.c */ #include #include #include main() { struct pollfd x[1]; int i; x[0].fd = 0; x[0].events = POLLIN; i = poll(x, 1, 10000); printf("retval = %d, revents=%d\n", i, x[0].revents); } /* end of poll-sample.c */ >Fix: This hasn't been tested yet, but I think changing the implementation of vop_stdpoll() in /sys/kern/vfs_default.c will solve this inconsistent behavior, by applying the following patch. --- /sys/kern/vfs_default.c Wed Jan 20 23:48:49 1999 +++ vfs_default.c Sat Feb 19 12:44:43 2000 @@ -285,7 +285,8 @@ } */ *ap; { if ((ap->a_events & ~POLLSTANDARD) == 0) - return (ap->a_events & (POLLRDNORM|POLLWRNORM)); + return (ap->a_events & + (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)); return (vn_pollrecord(ap->a_vp, ap->a_p, ap->a_events)); } I would also like FreeBSD Development Team to clarify the difference of semantics between POLLIN and POLLRDNORM, or POLLOUT and POLLWRNORM, and put the definition clearly on poll(2). >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message