tty \- general terminal interface
both a particular special file,
and the general nature of the terminal interface.
is, in each process, a synonym
for the control terminal associated with that process.
It is useful for programs that wish to
be sure of writing messages on the terminal
no matter how output has been redirected.
It can also be used for programs that demand a file name
for output, when typed output is desired
and it is tiresome to find out which terminal
As for terminals in general: all of the low-speed asynchronous
communications ports use the
same general interface, no matter what
The remainder of this section discusses
the common features of the interface
and differences resulting from the particular device,
KL-11 or DH-11, on which the interface is implemented.
When a terminal file is opened, it causes
the process to wait until a connection is established.
In practice user's programs seldom open these
files; they are opened by
The very first terminal file open in a process becomes
The control terminal plays a special
role in handling quit or interrupt signals, as discussed
The control terminal is inherited by a child process during a
even if the control terminal is closed.
The set of processes that thus share a control terminal
all members of a process group receive certain signals
together, see DEL below and
A terminal associated with one of these files ordinarily
operates in full-duplex mode.
Characters may be typed at any time,
even while output is occurring, and are only lost when the
system's character input buffers become completely
or when the user has accumulated the maximum allowed number of
input characters that have not yet been read by some program.
Currently this limit is 256 characters.
When the input limit is reached all the
saved characters are thrown away without notice.
Normally, terminal input is processed in units of lines.
This means that a program attempting
to read will be suspended until an entire line has been
Also, no matter how many characters are requested
in the read call, at most one line will be returned.
It is not however necessary to read a whole line at
once; any number of characters may be
requested in a read, even one, without losing information.
There are special modes, discussed below,
that permit the program to read each character as typed
without waiting for a full line.
During input, erase and kill processing is normally
By default, the character `#' erases the
last character typed, except that it will not erase
beyond the beginning of a line or an EOT.
By default, the character `@' kills the entire
line up to the point where it was typed, but not beyond an EOT.
characters operate on a keystroke basis independently
of any backspacing or tabbing that may have been done.
Either `@' or `#' may be entered literally by preceding
the erase or kill character remains, but the
These two characters may be changed to others.
all upper-case letters are mapped into
the corresponding lower-case letter.
The upper-case letter may be generated by preceding
In addition, the following escape sequences are generated
on output and accepted on input:
Certain ASCII control characters have special meaning.
These characters are not passed to a reading program
except in raw mode where they lose their special character.
(Control-D) may be used to generate an end of file
When an EOT is received, all the characters
waiting to be read are immediately passed to
the program, without waiting for a new-line,
and the EOT is discarded.
Thus if there are no characters waiting, which
is to say the EOT occurred at the beginning of a line,
zero characters will be passed back, and this is
the standard end-of-file indication.
is not passed to a program but generates
which is sent to all processes with the associated control terminal.
Normally each such process is forced to terminate,
but arrangements may be made either to
ignore the signal or to receive a
trap to an agreed-upon location.
(Control-\\ or control-shift-L)
Its treatment is identical to the interrupt signal
except that unless a receiving process has
made other arrangements it will not only be terminated
but a core image file will be generated.
(Control-S) delays all printing on the terminal
until something is typed in.
A second DC3 may be used to restart printing
without causing any input.
When the carrier signal from the dataset drops (usually
because the user has hung up his terminal)
signal is sent to all processes with the terminal
Unless other arrangements have been made,
this signal causes the processes to terminate.
If the hangup signal is ignored, any read
returns with an end-of-file indication.
Thus programs that read a terminal and test for
end-of-file on their input
can terminate appropriately when
characters are written, they are actually transmitted
to the terminal as soon as previously-written characters
Input characters are echoed by putting them in the output queue
When a process produces characters more rapidly than they can be typed,
it will be suspended when its output queue exceeds some limit.
When the queue has drained down to some threshold
Even parity is always generated on output.
The EOT character is not transmitted
that respond to it from hanging up.
calls apply to terminals.
Some of the use the following structure,
fields describe the input and output speeds of the
device according to the following table,
which corresponds to the DEC DH-11 interface.
If other hardware is used,
impossible speed changes are ignored.
Symbolic values in the table are as defined in
In the current configuration,
only 110, 150, 300 and 1200 baud are really supported on dial-up lines.
Code conversion and line control required for
must be implemented by the user's
The half-duplex line discipline
required for the 202 dataset (1200 baud)
is not supplied; full-duplex 212 datasets work fine.
fields of the argument structure
specify the erase and kill characters respectively.
field of the argument structure
contains several bits that determine the
system's treatment of the terminal:
.ta \w'ALLDELAY 'u +\w'0100000 'u
ALLDELAY 0177400 Delay algorithm selection
BSDELAY 0100000 Select backspace delays (not implemented):
VTDELAY 0040000 Select form-feed and vertical-tab delays:
CRDELAY 0030000 Select carriage-return delays:
TBDELAY 0006000 Select tab delays:
NLDELAY 0001400 Select new-line delays:
EVENP 0000200 Even parity allowed on input (most terminals)
ODDP 0000100 Odd parity allowed on input
RAW 0000040 Raw mode: wake up on all characters, 8-bit interface
CRMOD 0000020 Map CR into LF; echo LF or CR as CR-LF
ECHO 0000010 Echo (full duplex)
LCASE 0000004 Map upper case to lower on input
CBREAK 0000002 Return each character as soon as typed
The delay bits specify how long
transmission stops to allow for mechanical or other movement
when certain characters are sent to the terminal.
In all cases a value of 0 indicates no delay.
Backspace delays are currently ignored but might
be used for Terminet 300's.
If a form-feed/vertical tab delay is specified,
it lasts for about 2 seconds.
Carriage-return delay type 1 lasts about .08 seconds
and is suitable for the Terminet 300.
Delay type 2 lasts about .16 seconds and is suitable
for the VT05 and the TI 700.
Delay type 3 is unimplemented and is 0.
New-line delay type 1 is dependent on the current column
and is tuned for Teletype model 37's.
Type 2 is useful for the VT05 and is about .10 seconds.
Type 3 is unimplemented and is 0.
Tab delay type 1 is dependent on the amount of movement
and is tuned to the Teletype model
is not a delay at all but causes tabs to be replaced
by the appropriate number of spaces on output.
Characters with the wrong parity, as determined by bits 200 and
In raw mode, every character is passed immediately
to the program without waiting until a full line has been typed.
No erase or kill processing is done;
the end-of-file indicator (EOT), the interrupt character
(DEL) and the quit character (FS) are not treated specially.
There are no delays and no echoing, and no replacement of
one character for another;
characters are a full 8 bits for both input and output
(parity is up to the program).
Mode 020 causes input carriage returns to be turned into
input of either CR or LF causes LF-CR both to
(used for GE TermiNet 300's and other terminals without the newline function).
CBREAK is a sort of half-cooked mode.
Programs can read each character as soon as typed, instead
of waiting for a full line,
but quit and interrupt work, and output delays, case-translation,
CRMOD, XTABS, ECHO, and parity work normally.
On the other hand there is no erase or kill,
and no special treatment of \e or EOT.
.B ioctl(fildes, code, arg)
The applicable codes are:
Fetch the parameters associated with the terminal, and store
in the pointed-to structure.
Set the parameters according to the pointed-to strucutre.
The interface delays until output is quiescent,
then throws away any unread characters,
before changing the modes.
Set the parameters but do not delay of flush input.
With the collowing codes the
Set ``exclusive-use'' mode:
no further opens are permitted until the file has been closed.
Turns off ``exclusive-use'' mode.
When the file is closed for the last time,
This is useful when the line is associated
with an ACU used to place outgoing calls.
Speed cannot be changed on terminals attached to a KL-11;
the UNIX console, whose special use is described in
getty(8), stty (1), signal(2), ioctl(2)
Half-duplex terminals are not supported.
On raw-mode output, parity should be transmitted as specified
in the characters written.