1 .\" $NetBSD: 2.4.t,v 1.2 1998/01/09 06:54:50 perry Exp $
3 .\" Copyright (c) 1983, 1993, 1994
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)2.4.t 8.5 (Berkeley) 6/1/94
32 .Sh 2 "Terminals and Devices
40 as well as a collection of terminal specific
43 to control input character interpretation and editing,
44 and output format and delays.
46 A terminal may be used as a controlling terminal (login terminal)
48 A controlling terminal is associated with a session (see section
50 A controlling terminal has a foreground process group, which must be
51 a member of the session with which the terminal is associated (see section
53 Members of the foreground process group are allowed to read from and write to
54 the terminal and change the terminal settings; other process groups from
55 the session may be stopped upon attempts to do these operations.
57 A session leader allocates a terminal
58 as the controlling terminal for its session using the ioctl
60 ioctl(fd, TIOCSCTTY, NULL);
63 Only a session leader may acquire a controlling terminal.
67 Terminals are handled according to the underlying communication
68 characteristics such as baud rate and required delays,
69 and a set of software parameters.
70 These parameters are described in the \fItermios\fP structure
71 maintained by the kernel for each terminal line:
77 tcflag_t c_iflag; /* input flags */
78 tcflag_t c_oflag; /* output flags */
79 tcflag_t c_cflag; /* control flags */
80 tcflag_t c_lflag; /* local flags */
81 cc_t c_cc[NCCS]; /* control chars */
82 long c_ispeed; /* input speed */
83 long c_ospeed; /* output speed */
87 The \fItermios\fP structure is set and retrieved using the
93 Two general kinds of input processing are available, determined by
94 whether the terminal device file is in canonical mode or noncanonical
95 mode. Additionally, input characters are processed according to the
96 \fIc_iflag\fP and \fIc_lflag\fP fields.
97 Such processing can include echoing, which
98 in general means transmitting input characters immediately back to the
99 terminal when they are received from the terminal.
100 Non-graphic ASCII input characters may be echoed as a two-character
101 printable representation, ``^character.''
103 In canonical mode input processing,
104 terminal input is processed in units of lines.
105 A line is delimited by a newline character (NL),
106 an end-of-file (EOF) character, or an end-of-line (EOL) character.
107 Input is presented on a line-by-line basis.
108 Using this mode means that a read request will not return
109 until an entire line has been typed,
110 or a signal has been received.
111 Also, no matter how many bytes are requested
112 in the read call, at most one line is returned.
113 It is not, however, necessary to read a whole line at once;
114 any number of bytes, even one, may
115 be requested in a read without losing information.
117 When the terminal is in canonical mode, editing of an input line
118 is performed. Editing facilities allow deletion of the previous
119 character or word, or deletion of the current input line.
121 a special character may be used to reprint the current input line.
122 Certain other characters are also interpreted specially.
123 Flow control is provided by the \fIstop output\fP
124 and \fIstart output\fP control characters.
125 Output may be flushed with the \fIflush output\fP character;
126 and the \fIliteral character\fP may be used to force the following
127 character into the input line, regardless of any special meaning
130 In noncanonical mode input processing, input bytes are not assembled into
131 lines, and erase and kill processing does not occur.
132 All input is passed through to the
133 reading process immediately and without interpretation.
134 Signals and flow control may be enabled; here
135 the handler interprets input only by looking
136 for characters that cause interrupts or output flow control;
137 all other characters are made available.
139 When interrupt characters are being interpreted
140 by the terminal handler they
141 cause a software interrupt to be sent to all processes in the process
142 group associated with the terminal.
143 Interrupt characters exist to send SIGINT
145 and to stop a process group
146 with the SIGTSTP signal either immediately, or when
147 all input up to the stop character has been read.
148 .Sh 4 "Terminal output
150 On output, the terminal handler provides some simple formatting services.
151 These include converting the carriage return character to the
152 two character return-linefeed sequence,
153 inserting delays after certain standard control characters,
156 .Sh 3 "Structured devices
158 Structured devices are typified by disks and magnetic
159 tapes, but may represent any random-access device.
160 The system performs read-modify-write type buffering actions on block
161 devices to allow them to be read and written in random access
162 fashion like ordinary files.
163 Filesystems are normally mounted on block devices.
165 .Sh 3 "Unstructured devices
167 Unstructured devices are those devices which
168 do not support block structure. Familiar unstructured devices
169 are raw communications lines (with
170 no terminal handler), raster plotters, magnetic tape and disks unfettered
171 by buffering and permitting large block input/output and positioning
172 and formatting commands.