Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: comp.unix.programmer Subject: Re: select function Message-ID: <1991Mar26.065725.763@thunder.mcrcim.mcgill.edu> Date: 26 Mar 91 06:57:25 GMT References: <27E85B3B.14962@ics.uci.edu> Organization: McGill Research Centre for Intelligent Machines Lines: 27 In article <27E85B3B.14962@ics.uci.edu>, djpadz@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@larry.mcrcim.mcgill.edu