Advanced Programming in the
UNIX Environment

by W. Richard Stevens
Addison-Wesley Professional Computing Series
0-201-56317-7 * Hardcover * 768 pages * ©1992
[Buy this book]

Chapter 11. Terminal I/O

Introduction * Overview * Special Input Characters * Getting and Setting Terminal Attributes * Terminal Option Flags * stty Command * Baud Rate Functions * Line Control Functions * Terminal Identification * Canonical Mode * Noncanonical Mode * Terminal Window Size * termcap, terminfo, and curses * Summary

Example Relevant Functions
11.1 Terminal settings: disable the interrupt char and change the EOF char isatty, fpathconf tcgetattr, tcsetattr
11.2 Get teminal #bits/byte setting and set it to 8-bit char tcgetattr, tcsetattr
11.3 POSIX.1 termid implementation:
Identify the device associated with tty
Nothing interesting
(dummy function returning "/dev/tty"
for portability to non UNIX systems)
11.4 POSIX.1 isatty implementation:
Is this file descriptor associated with a tty device?
isatty
11.5 Test program for 11.4 above isatty
11.6 POSIX.1 ttyname implementation:
What is the name of terminal device
associated with this file descriptor ?
isatty, fstat, stat,
opendir, readdir, closedir,
strcpy, strncpy
11.7 Test program for 11.6 above isatty, ttyname
11.8 POSIX.1 getpass implementation:
Read a password from the controlling terminal
with echo disabled and proper signal handling.
fopen, setbuf,
sigemptyset, sigaddset, sigprocmask,
tcgetattr, tcsetattr,
fputs, getc, putc, fclose
11.9 Test program for 11.8 above getpass
11.10 A set of useful terminal handling functions:
tty_cbreak: Put controlling terminal in break mode
tty_raw: Put controlling terminal in raw mode
tty_reset: Reset terminal modes.
tty_termios: Return saved terminal modes.
tty_atexit: Reset terminal modes on exit,
(when registered with atexit)
tcgetattr, tcsetattr
11.11 Test program for 11.10 above signal,
tty_cbreak, tty_raw, tty_reset,
read (single-char, unbuffered),
11.12 Print window size whenever it changes isatty, signal, pause, ioctl

[Buy this book]