Add Book to My BookshelfPurchase This Book Online

Chapter 12 - Terminals

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

Chapter 12: Terminals
Overview
Terminal I/O is probably the messiest topic in UNIX systems programming; it is certainly the biggest stumbling block to portability. The problem is that serial lines are used for so many different things, such as connecting terminals to the system, communicating with printers, hooking up modems, and talking to specialized devices. Each of these uses has its own needs, and while they all overlap to some extent, the terminal interface has had to be extended each time a new use arose. The end result is that things have gotten very complex—the interface is pretty straightforward, but the number of options has grown so large that it's difficult to know which ones to choose. This is true not just for UNIX, but for any operating system that allows the programmer to control serial port processing.
The other problem with terminal I/O control is that the UNIX community historically supported two different, and incompatible, interfaces. The original interface was developed for Version 7, and was based on the stty and ioctl functions. Berkeley later extended this interface to cover the additional functionality added by their versions of the operating system, and this interface is present in all versions of BSD UNIX save the last (which has adopted the POSIX interface). The other interface was first developed in System III, and has continued forward through all releases of System V, including SVR4 (although its presence there is primarily for backward compatibility; the POSIX interface is preferred).
When the System III interface first became public, many programmers (including the author) viewed it as a gratuitous change made solely for the purpose of being different. However, in reality, the change was made with the best of intentions. The original Version 7 interface, especially as extended by Berkeley, was showing its age. It was made up of several different data structures, each used for different purposes, representing, in a way, its rather piecemeal development process. The designers of System III recognized this and, more importantly, recognized that as other extensions became necessary in the future, they would probably have to be “grafted onto” the interface, rather than integrated with it. So, they designed a new interface that unified all of the parts from the old interface, as well as some new capabilities, into a single, coherent whole. Furthermore, they designed the interface in such a way that new functionality could be added within the existing framework, rather than by extending the interface in incompatible ways. Although the first versions of this new interface suffered from a few deficiencies, these have since been fixed, and the interface has indeed met the goals set for it by the designers, while the older interface has been all but discarded. Indeed, when the POSIX committee specified a terminal I/O control interface, they chose one based on (in fact, nearly identical to) the System III/System V interface.
In this chapter, we will examine the issue of terminal I/O control in detail. We begin by discussing the topic at a high level, in order to introduce many of the concepts necessary to understand the remainder of the chapter. We follow this with a discussion of the POSIX terminal control interface; this interface is perhaps the easiest to understand. After presenting the POSIX interface, we present the System V interface, on which it is based. And then, because there are so many programs that must be ported from the BSD environment to SVR4, we present the Berkeley interface in detail.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback