HOME

TheInfoList



OR:

The Seventh Edition Unix terminal interface is the generalized abstraction, comprising both an application programming interface for programs and a set of behavioural expectations for users, of a
terminal Terminal may refer to: Computing Hardware * Terminal (electronics), a device for joining electrical circuits together * Terminal (telecommunication), a device communicating over a line * Computer terminal, a set of primary input and output devic ...
as historically available in
Seventh Edition Unix Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercial ...
. It has been largely superseded by the POSIX terminal interface.


Concepts and overview

The terminal interface provided by Seventh Edition Unix and
UNIX/32V UNIX/32V is an early version of the Unix operating system from Bell Laboratories, released in June 1979. 32V was a direct port of the Seventh Edition Unix to the DEC VAX architecture. Overview Before 32V, Unix had primarily run on DEC P ...
, and also presented by
BSD The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Be ...
version 4 as the ''old terminal driver'', was a simple one, largely geared towards
teletypewriter A teleprinter (teletypewriter, teletype or TTY) is an electromechanical device that can be used to send and receive typed messages through various communications channels, in both point-to-point and point-to-multipoint configurations. Initia ...
s as terminals. Input was entered a line at a time, with the terminal driver in the operating system (and not the terminals themselves) providing simple line editing capabilities. A buffer was maintained by the kernel in which editing took place. Applications reading terminal input would receive the contents of the buffer only when the key was pressed on the terminal to end line editing. The key sent from the terminal to the system would erase ("kill") the entire current contents of the editing buffer, and would be normally displayed as an '@' symbol followed by a newline sequence to move the print position to a fresh blank line. The key sent from the terminal to the system would erase the last character from the end of the editing buffer, and would be normally displayed as an '#' symbol, which users would have to recognize as denoting a "rubout" of the preceding character (teletypewriters not being physically capable of erasing characters once they have been printed on the paper). From a programming point of view, a terminal device had transmit and receive
baud rate In telecommunication and electronics, baud (; symbol: Bd) is a common unit of measurement of symbol rate, which is one of the components that determine the speed of communication over a data channel. It is the unit for symbol rate or modulatio ...
s, "erase" and "kill" characters (that performed line editing, as explained), "interrupt" and "quit" characters (generating
signal In signal processing, a signal is a function that conveys information about a phenomenon. Any quantity that can vary over space or time can be used as a signal to share messages between observers. The '' IEEE Transactions on Signal Processing' ...
s to all of the processes for which the terminal was a controlling terminal), "start" and "stop" characters (used for
software flow control Software flow control is a method of flow control used in computer data links, especially RS-232 serial. It uses special codes, transmitted in-band, over the primary communications channel. These codes are generally called XOFF and XON (from ...
), an "end of file" character (acting like a carriage return except discarded from the buffer by the read() system call and therefore potentially causing a zero-length result to be returned) and various ''mode flags'' determining whether
local echo In telecommunications, echo is the local display of data, either ''initially'' as it is locally sourced and sent, or ''finally'' as a copy of it is received back from a remote destination. Local echo is where the ''local'' sending equipment display ...
was emulated by the kernel's terminal driver, whether modem flow control was enabled, the lengths of various output delays, mapping for the carriage return character, and the three input modes.


Input modes

The three input modes for terminals in Seventh Edition Unix were: ;line mode (also called "cooked" mode):In line mode the line discipline performs all line editing functions and recognizes the "interrupt" and "quit" control characters and transforms them into signals sent to processes. Applications programs reading from the terminal receive entire lines, after line editing has been completed by the user pressing return. ;cbreak mode:cbreak mode is one of two character-at-a-time modes. (
Stephen R. Bourne Stephen Richard "Steve" Bourne (born 7 January 1944) is an English computer scientist based in the United States for most of his career. He is well known as the author of the Bourne shell (sh), which is the foundation for the standard command-li ...
jokingly referred to it as a "half-cooked" and therefore "rare" mode.) The line discipline performs no line editing, and the control sequences for line editing functions are treated as normal character input. Applications programs reading from the terminal receive characters immediately, as soon as they are available in the input queue to be read. However, the "interrupt" and "quit" control characters, as well as modem flow control characters, are still handled specially and stripped from the input stream. ;raw mode:raw mode is the other of the two character-at-a-time modes. The line discipline performs no line editing, and the control sequences for both line editing functions and the various special characters ("interrupt", "quit", and flow control) are treated as normal character input. Applications programs reading from the terminal receive characters immediately, and receive the entire character stream unaltered, just as it came from the terminal device itself. In the POSIX terminal interface, these modes have been superseded by a system of just two input modes: canonical and non-canonical. The handling of signal-generating special characters in the POSIX terminal interface is independent of input mode, and is separately controllable.


Controlling terminals

In Seventh Edition Unix there was no terminal job control and a
process group In a POSIX-conformant operating system, a process group denotes a collection of one or more processes. Among other things, a process group is used to control the distribution of a signal; when a signal is directed to a process group, the signal is ...
was considered to be not what it is considered to be nowadays. Each
process A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic. Things called a process include: Business and management *Business process, activities that produce a specific se ...
in the system had either a single ''controlling terminal'', or no controlling terminal at all. A process inherits its controlling terminal from its parent. A controlling terminal was acquired when a process with no controlling terminal open()s a terminal device file that isn't already the controlling terminal for some other process. All of the processes that had the same controlling terminal were part of a single ''process group''.


Application programming interface

The programmatic interface for querying and modifying all of these modes and control characters was the ioctl() system call. (This replaced the stty() and gtty() system calls of Sixth Edition Unix.) Although the "erase" and "kill" characters were modifiable from their defaults of and , for many years after Seventh Edition development inertia meant that they were the pre-set defaults in the terminal device drivers, and on many Unix systems, which only altered terminal device settings as part of the login process, in system login scripts that ran ''after'' the user had entered username and password, any mistakes at the login and password prompts had to be corrected using the historical editing key characters inherited from teletypewriter terminals. The symbolic constants, whose values were fixed and defined, and data structure definitions of the programmatic interface were defined in the sgtty.h system header.


ioctl() operations

The ioctl() operations were as follows:


The sgttyb data structure

One data structure used by the terminal system calls is the sgttyb structure, whose C programming language definition is as follows:struct sgttyb ; Unlike the POSIX terminal interface, the Seventh Edition Unix terminal interface recorded input and output baud rates directly in the data structure. The input and output speeds in the sg_ispeed and sg_ospeed fields were those of the DEC DH-11, and were the numbers 0 to 15, represented by the symbolic constants (in ascending order) B0, B50, B75, B110,B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, B9600, EXTA, and EXTB, where the baud rate was as in the name (with the last two being "external A" and "external B"). Setting a baud rate of zero forced the terminal driver to hang up a modem (if the terminal was a modem device). The sg_erase and sg_kill fields were simply the character values of the "erase" and "kill" characters, respectively, defaulting to the (ASCII) values for '' and '' respectively. The sg_flags field specified various input and output control flags, as in the following table.


The tchars data structure

One data structure used by the terminal system calls is the tchars structure, whose C programming language definition is as follows:struct tchars ; The values of these fields were the values of the various programmatically configurable special characters. A -1 value in any field disabled its recognition by the terminal driver.


References


Bibliography

* * * * {{refend Application programming interfaces Bell Labs Unices Berkeley Software Distribution Computer terminals Technical communication