From owner-freebsd-bugs Thu Nov 18 8:10: 7 1999 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 A52FF15516 for ; Thu, 18 Nov 1999 08:10:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id IAA04577; Thu, 18 Nov 1999 08:10:00 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from f434.n5020.z2.fidonet.org (host5.mtelecom.ru [212.44.147.5]) by hub.freebsd.org (Postfix) with ESMTP id B2C0E15441 for ; Thu, 18 Nov 1999 08:02:33 -0800 (PST) (envelope-from seva@p1.f434.n5020.z2.fidonet.org) Received: from p1.f434.n5020.z2.fidonet.org (p1 [192.168.44.37]) by f434.n5020.z2.fidonet.org (8.8.8/8.8.8) with ESMTP id TAA24809 for ; Thu, 18 Nov 1999 19:00:18 +0300 (MSK) (envelope-from seva@p1.f434.n5020.z2.fidonet.org) Received: (from seva@localhost) by p1.f434.n5020.z2.fidonet.org (8.9.3/8.9.3) id TAA22164; Thu, 18 Nov 1999 19:14:35 +0300 (MSK) (envelope-from seva) Message-Id: <199911181614.TAA22164@p1.f434.n5020.z2.fidonet.org> Date: Thu, 18 Nov 1999 19:14:35 +0300 (MSK) From: seva@mtelecom.ru Reply-To: seva@mtelecom.ru To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/14979: select/poll handler for fifo is broken in FreeBSD-3.X Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 14979 >Category: kern >Synopsis: fifo's select(2)/poll(2) handler is broken in FreeBSD-3.X >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Nov 18 08:10:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Seva Semenov >Release: FreeBSD 3.2-RELEASE i386 >Organization: Seva's Bedroom >Environment: FreeBSD 3.3 RELEASE and FreeBSD 3.2 RELEASE >Description: when fifo (maden by mkfifo(1)) has select(2)ed or poll(2)ed select(2) and poll(2) returns without timeout even fifo has no bytes to read. In FreeBSD 2.X and NetBSD 1.4.1 there is timeout as expected. >How-To-Repeat: # mkfifo fifo # cat readfifo.select.c #include #include #include #include #include #include #include #include int main(int argc,char **argv) { int fd; char *fn="fifo"; if(argc>1) fn=*(argv+1); if((fd=open(fn,O_RDONLY|O_NONBLOCK))<0) err(errno,"can't open %s",fn); for(;;){ fd_set fds; int r; struct timeval tv; size_t sz; char b[64]; tv.tv_sec=5; tv.tv_usec=0; FD_ZERO(&fds); FD_SET(fd,&fds); r=select(FD_SETSIZE,&fds,NULL,NULL,&tv); if(r<0) err(errno,"select return %d ",r); if(r==0){ fputs("timeout\n",stderr); continue; } sz=read(fd,b,63); if(sz<0) err(errno,"read fifo return %d",sz); if(!sz){ fputs("read null bites\n",stderr); continue; } b[sz]='\0'; puts(b); fflush(stdout); } } # cat readfifo.poll.c #include #include #include #include #include #include #include #include int main(int argc,char **argv) { int fd; char *fn="fifo"; if(argc>1) fn=*(argv+1); fd=open(fn,O_RDONLY|O_NONBLOCK); if(fd<0) err(errno,"cannot open %s",fn); for(;;){ struct pollfd pfd; int pr; size_t sz; char b[64]; pfd.fd=fd; /*pfd.events=POLLRDNORM;*/ pfd.events=POLLIN; pr=poll(&pfd,1,5000); if(pr==-1) err(errno,"error in poll"); if(!pr){ fputs("timeout\n",stderr); continue; } puts("reading");fflush(stdout); sz=read(fd,b,63); if(sz<0) err(errno,"cannot read"); if(!sz){ fputs("read null bytes\n",stderr); continue; } b[sz]='\0'; puts(b); fflush(stdout); } } # make readfifo.select # make readfifo.poll # ./readfifo.select >Fix: I don't know. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message