> 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) ) {
> ......
> }
> }
> }
It looks like you are sending the original fd_set to select. Remember that
it is modified in place. What is probably happening is that select returns
at once when it gets something from /dev/random, and rfds is now modified
to only contain this. The next time select runs, it will only be checking
for input from /dev/random. You have to make a copy of rfds that is set
every time, and send that instead.
Ketil
-
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/