[ale] keystrokes

Jeff Barber jeffb at issl.atl.hp.com
Wed Oct 30 09:12:16 EST 1996


Jacob Langseth writes:

> This _should_ do it... however, getchar() seems to block until it gets a
> newline, both under SunOS and linux (why? anyone?).

This is a function of the terminal device driver in the kernel.  When
in "canonical" mode, it buffers input a line at a time.  It can be
controlled programmatically though.  Use the functions in termios(2) to
change the settings.  Specifically, what you want to do can be done by
retrieving the current settings with tcgetattr(), turning off the ICANON
bit in the c_lflags field, using tcsetattr() to set the new state, then
doing the getchar().  Finally, when you're done, clean up by doing
tcsetattr() with the original state again.  (I'm not sure what the
SunOS versions of these functions are, but they'll be similar if not
identical.)

stty -icanon


-- Jeff






More information about the Ale mailing list