Re: Select with device and stdin not working

Richard B. Johnson (root@chaos.analogic.com)
Wed, 25 Jul 2001 11:07:04 -0400 (EDT)


On Wed, 25 Jul 2001, Ben Greear wrote:

> "M. Tavasti" wrote:
> >
> > I found this problem first time in 2.2 kernels, when doing own device
> > driver. Then it was not an issue for me, and I suspected it's my
> > fault. Now, with 2.4 again I tried to solve problem, but I can't find
> > my way out of this, and looks like there in-kernel drivers which have
> > same symptoms.
> >
> > Here program where I get problems:
> >
> > int fd;
> > fd_set rfds;
> >
> > fd = open("/dev/random", O_RDWR );
> >
> > while(1) {
> > FD_ZERO(&rfds);
> > FD_SET(fd,&rfds);
> > FD_SET(fileno(stdin),&rfds);
> > if( select(fd+1, &rfds, NULL, NULL, NULL ) > 0) {
> > fprintf(stderr,"Select\n");
> > fflush(stderr);
> > if(FD_ISSET(fd,&rfds)) {
> > .......
> > } else if(FD_ISSET(fileno(stdin),&rfds) ) {
> > ......
> > }
> > }
> > }

Change:
} else if(FD_ISSET(fileno(stdin),&rfds) ) {
To:
} if(FD_ISSET(fileno(stdin),&rfds) ) {

Both of these bits can be (probably are) set.

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/