ReadKey like Function in C

Jeff Aguilera jeffa at hpmwtd.HP.COM
Sat Aug 12 03:12:53 AEST 1989


> Absolutely!  You need only do the following:
> 
> 1.  do an "ioctl (n, TCGETA, &term)
> 2.  modify some parameters, such as
>     term.c_lflag &= ~(ICANON | ECHO)  or whatever else you need
> 3.  term.c_cc [VTIME] = some_value  <- for timeout, if desired
> 4.  term.c_cc [VMIN] = 1  <- satisfy read with 1 character
> 5.  ioctl (m, TCSETA, &term)  to reset the terminal
> 6.  you can now do a read (n, &work, 10)  

Close.  If a timeout is specified, set term.c_cc[VMIN] = 0.  
Otherwise the timer is not started until receipt of the
first character; i.e., the program can still wait forever.



More information about the Comp.lang.c mailing list