mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Select with device and stdin not working
@ 2001-07-25 12:17 M. Tavasti
  2001-07-25 13:53 ` Ketil Froyn
  2001-07-25 15:02 ` Ben Greear
  0 siblings, 2 replies; 11+ messages in thread
From: M. Tavasti @ 2001-07-25 12:17 UTC (permalink / raw)
  To: linux-kernel


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) ) { 
                 ......
                }
        }
}


Select is working fine for device (in this example /dev/random) or
stdin. But for both, not. When entering something to stdin, it's not
sure select will return. 

I haven't tested is this problem present in all devices, but at least
/dev/random is infected. And if problem lies only in some of the
drivers, it would be nice to know which driver haves decent
implementation of poll and get others updated. 

I'm not subsribed on the list, so when replying this you may consider
Cc:ing me. 

-- 
M. Tavasti /  tawz@nic.fi  /   +358-40-5078254

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Select with device and stdin not working
@ 2001-07-25 14:14 Stephen Landamore
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Landamore @ 2001-07-25 14:14 UTC (permalink / raw)
  To: linux-kernel

> Select is working fine for device (in this example /dev/random) or
> stdin. But for both, not. When entering something to stdin, it's not
> sure select will return.

If stdin is a tty, chances are select will not show any data ready
until you hit return - this is canonical mode (or cooked mode).  Try
clearing canonical mode (or setting cbreak / raw mode).

In the case of stdin being a tty, and you are typing away, note that
your keypresses will generate entropy - so /dev/random probably will
become ready to read before stdin ;)

cheers,
stephen

--
Stephen Landamore, <slandamore@zeus.com>              Zeus Technology
Tel: +44 1223 525000                      Universally Serving the Net
Fax: +44 1223 525100                              http://www.zeus.com
Zeus Technology, Zeus House, Cowley Road, Cambridge, CB4 0ZT, ENGLAND


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-07-26 14:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-25 12:17 Select with device and stdin not working M. Tavasti
2001-07-25 13:53 ` Ketil Froyn
2001-07-25 13:35   ` M. Tavasti
2001-07-25 14:54     ` Ketil Froyn
2001-07-25 15:02 ` Ben Greear
2001-07-25 15:07   ` Richard B. Johnson
2001-07-25 15:27     ` M. Tavasti
2001-07-25 15:45       ` Richard B. Johnson
2001-07-26 12:06         ` M. Tavasti
2001-07-26 13:20           ` M. Tavasti
2001-07-25 14:14 Stephen Landamore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®