select question

Neal D. Becker nbecker@hns.com
Mon Nov 25 12:42:00 GMT 2002


I'm trying to use select to see if there is any user input (that would
be stdin, file descriptor 0).  If not I want to run my background
computation.  I want to execute this loop at a pretty high rate (on
the order of 100 usec).

I tried the following:

	fd_set set;
	FD_ZERO(&set);
	FD_SET (0, &set);

	timeval timeout;
	timeout.tv_usec = 200;
	timeout.tv_sec = 0;

	int res = select (1, &set, 0, 0, &timeout);
	if (res == 0) {
          do computation
        else
          read user input

The problem is it seems to be ignoring the user input, even though the
load average (as reported by top) is still quite low.

Is there a problem with select being used this way?  Is there a better
way to implement this with cygwin?


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list