select function

der Mouse mouse at thunder.mcrcim.mcgill.edu
Tue Mar 26 16:57:25 AEST 1991


In article <27E85B3B.14962 at ics.uci.edu>, djpadz at bonnie.ics.uci.edu (David Jay Padzensky) writes:
> I'm writing a program that needs to use the select function to poll
> for TTY input.  All I need for it to do is, given a timeout value (in
> milliseconds), return a boolean value as to whether or not a key was
> pressed in that time.  However, I'm having no luck with the thing.
> Could somebody help me out?

Not without more information, really.

One possible problem that comes to mind is that you may have neglected
to put the tty line in question into cbreak or raw mode (I assume a BSD
tty driver because you're using select()).

Note also that you generally won't get very good temporal resolution.
Most machines with UNIXish systems have clocks that tick at about 50 Hz
(sometimes 60, sometimes 100, but rarely much better than that); your
timeout will necessarily expire on a clock tick.  (You also won't
necessarily get control back immediately after the timeout expires;
other processes may run first.)

If you have a small sample program, I'd be glad to have a look at it.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.unix.programmer mailing list