How can I read keyboard without stopping

Phong Vo[eww] kpv at ulysses.homer.nj.att.com
Mon Aug 15 23:20:11 AEST 1988


In article <1246 at mcgill-vision.UUCP>, mouse at mcgill-vision.UUCP (der Mouse) writes:
> In article <813 at ms3.UUCP>, isns02 at ms3.UUCP (Harris Reavin) writes:
> > I would like to know if it is possible to get input data from the
> > keyboard while my program is constantly looping and displaying output
> > to the screen.  The input comes from a call to "popen()".
> 
> 
> I know of at least four ways to do this (read without jamming the whole
> process), of varying degrees of portability and functionality.
...four different ways described ... 

Functionality such as this is required frequently enough and its implementation
is reasonably hard for ensuring portability across different UNIX flavors that
I think it ought to be a part of a standard package such as curses.
In a version of curses that I wrote a number of years back, there is a function
wtimeout(WINDOW *win,int delay) which let users define a delay in miniseconds
for getting keyboard inputs. Delay < 0 means blocking on reads, delay == 0 means
no blocking, and so on. This can be implemented nicely with select().
On systems without select() or an equivalent function,
it can be simulated with a hack using fcntl() and times().
This curses is now distributed with a version of system V.
	Phong Vo, AT&T Bell Labs, ulysses!kpv



More information about the Comp.unix.wizards mailing list