This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

select question


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]