Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

18


Terminal I/O


18.1 Introduction


The handling of terminal I/O is a messy area, regardless of the operating system. The
UNIX System is no exception. The manual page for terminal I/O is usually one of the
longest in most editions of the programmer ’s manuals.
With the UNIX System, a schism formed in the late 1970s when System III
developed a different set of terminal routines from those of Version 7. The System III
style of terminal I/O continued through System V,and the Version 7 style became the
standardfor the BSD-derived systems. As with signals, this difference between the two
worlds has been conquered by POSIX.1. In this chapter, we look at all the POSIX.1
terminal functions and some of the platform-specific additions.
Part of the complexity of the terminal I/O system occurs because people use
terminal I/O for so many different things: terminals, hard-wired lines between
computers, modems, printers, and so on.

18.2 Overview


Te rminal I/O has two modes:


  1. Canonical mode input processing. In this mode, terminal input is processed as
    lines. The terminal driver returns at most one line per read request.

  2. Noncanonical mode input processing. The input characters arenot assembled
    into lines.


671
Free download pdf