11/3/71                                   /DEV/TTY0 ... TTY5 (IV)





NAME            tty0 ... tty5 -- communications interfaces



SYNOPSIS        --



DESCRIPTION     These files refer to DC11 asynchronous communica-

                tions interfaces.  At the moment there are six of

                them, but the number is subject to change.  Names

                for up to four others will be constructed by an

                obvious algorithm.



                When one of these files is opened, it causes the

                process to wait until a connection is estab-

                lished.  (In practice, however, user's programs

                seldom open these files; they are opened by init

                and become a user's standard input and output

                file.)  The very first typewriter file open in a

                process becomes the control typewriter for that

                process.  The control typewriter plays a special

                role in the handling quit or interrupt signals,

                as discussed below.  The control typewriter is

                inherited by a child process during a fork.



                A terminal associated with one of these files or-

                dinarily operates in full-duplex mode.  Charac-

                ters may be typed at any time, even while output

                is occurring, and are only lost when the system's

                character input buffers become completely choked,

                which is rare.



                When first opened, the interface expects the ter-

                minal to use 15 odd-parity, 10-bit ASCII charac-

                ters per second and to have the new-line func-

                tion.  Finally, the system calculates delays af-

                ter sending the code for certain functions (e.g.,

                new-line, tab) on the assumption that the termi-

                nal is a Teletype model 37.  All this is merely a

                long way of saying that the system expects to be

                used by a TTY 37.  However, most of these assump-

                tions can be changed by a special system call: in

                particular, the expected parity can be changed;

                the speed, character size, and stop bits can be

                changed (speeds available are 134.5, 150, 300,

                1200 baud; see the DC11 manual); the new-line

                function can be simulated by a combination of the

                carriage-return and line-feed functions; carriage

                return can be translated into new-line on input;

                upper case letters can be mapped into lower case

                letters; echoing can be turned off so the termi-

                nal operates in half duplex.  See the system call

                stty.  (Also see init for the way 300-baud termi-

                nals are detected.)



                Normally, a typewriter operates in units of

                lines.  This means that a program attempting to

                read will be suspended until an entire line has

                been typed.  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 charac-

                ters may be requested in a read, even one, with-

                out losing information.



                The EOT character may be used to generate an end

                of file from a typewriter.  When an EOT is re-

                ceived, all the characters waiting to be read are

                immediately passed to the program, without wait-

                ing for a new-line.  Thus if there are no charac-

                ters 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

                signal.



                When the carrier signal from the dataset drops

                (usually because the user has hung up his termi-

                nal) any read returns with an end-of-file indica-

                tion.  Thus programs which read a typewriter and

                are sensitive to end-of-file on their inputs

                (which all programs would be) will terminate ap-

                propriately when hung up on.



                Two characters have a special meaning when typed.

                The ASCII DEL character (sometimes called "rub-

                out") is the interrupt signal.  When this charac-

                ter is received from a given typewriter, a search

                is made for all processes which have this type-

                writer as their control typewriter, and which

                have not informed the system that they wish to

                ignore interrupts.  If there is more than one

                such process, one of these is selected, for prac-

                tical purposes at random.  Then either the pro-

                cess is forced to exit or a trap is simulated to

                an agreed-upon location in the process.  See sys

                intr for more information.



                The ASCII character FS is the quit signal.  Its

                treatment is identical to the interrupt signal

                except that unless the receiving process has made

                other arrangements it will not only be terminated

                but a core image file will be written.  (See sys

                quit for more information.)



                During input, erase and kill processing is nor-

                mally done.  The character "#" erases the last

                character typed, except that it will not erase

                beyond the beginning of a line or an EOT.  The

                character "@" kills the entire line up to the

                point where it was typed, but not beyond an EOT.

                Both these characters operate on a keystroke ba-

                sis independently of any backspacing or tabbing

                that may have been done.  Either "@" or "#" may

                be entered literally by preceding it by "\"; the

                erase or kill character remains, but the "\" dis-

                appears.



                It is also possible (again by sys stty) to put

                the typewriter into raw mode.  In this mode, the

                program reading is awakened on each character,

                and when a program reads, it waits only until at

                least one character has been typed.  In raw mode,

                no erase or kill processing is done; and the EOT,

                quit and interrupt characters are not treated

                specially.



                Output is prosaic compared to input.  It should

                be noted, however, that when one or more charac-

                ters are written, they are actually transmitted

                to the terminal as soon as previously-written

                characters have finished typing.  When a program

                produces characters too rapidly to be typed, as

                is very common, it may be suspended for a time.



                Odd parity is always generated on output, except

                that the characters EOT and NAK have the wrong

                parity.  Thus the 37 TTY will not hang up (EOT)

                or lock its keyboard (NAK) if a program acciden-

                tally prints these characters.



FILES           --



SEE ALSO        tty



DIAGNOSTICS     --



BUGS            As has been suggested, UNIX has a heavy predispo-

                sition towards 37 Teletype terminals.  However,

                it is quite possible to use 300-baud terminals

                such as the GE TermiNet 300.  (See init for the

                procedure.)  The main difficulty in practice is

                37-oriented delay calculations.



                Terminals such as the IBM 2741 would theoreti-

                cally be very desirable but there are many diffi-

                culties related to its inadequate and non-ASCII

                character sets (the 2741 has two, count 'em) and

                the inherently half-duplex nature of the termi-

                nal.  It is possible to produce output on a 2741;

                cf type.



OWNER           ken, dmr