xref: /illumos-gate/usr/src/man/man4i/termio.4i (revision 899b7fc7762875c5244567fbc6bb4ccace75d6f7)
1bbf21555SRichard Lowe.\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
2bbf21555SRichard Lowe.\" Copyright 2019, Joyent, Inc.  All Rights Reserved.
3bbf21555SRichard Lowe.\" Copyright 1989 AT&T
4bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the
5bbf21555SRichard Lowe.\" Common Development and Distribution License (the "License").
6bbf21555SRichard Lowe.\" You may not use this file except in compliance with the License.
7bbf21555SRichard Lowe.\"
8bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9bbf21555SRichard Lowe.\" or http://www.opensolaris.org/os/licensing.
10bbf21555SRichard Lowe.\" See the License for the specific language governing permissions
11bbf21555SRichard Lowe.\" and limitations under the License.
12bbf21555SRichard Lowe.\"
13bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each
14bbf21555SRichard Lowe.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15bbf21555SRichard Lowe.\" If applicable, add the following below this CDDL HEADER, with the
16bbf21555SRichard Lowe.\" fields enclosed by brackets "[]" replaced with your own identifying
17bbf21555SRichard Lowe.\" information: Portions Copyright [yyyy] [name of copyright owner]
18*899b7fc7SPeter Tribble.Dd March 13, 2022
19bbf21555SRichard Lowe.Dt TERMIO 4I
20bbf21555SRichard Lowe.Os
21bbf21555SRichard Lowe.Sh NAME
22bbf21555SRichard Lowe.Nm termio
23bbf21555SRichard Lowe.Nd general terminal interface
24bbf21555SRichard Lowe.Sh SYNOPSIS
25bbf21555SRichard Lowe.In termio.h
26bbf21555SRichard Lowe.Fn ioctl "int fildes" "int request" "struct termio *arg"
27bbf21555SRichard Lowe.Fn ioctl "int fildes" "int request" "int arg"
28bbf21555SRichard Lowe.Pp
29bbf21555SRichard Lowe.In termios.h
30bbf21555SRichard Lowe.Fn ioctl "int fildes" "int request" "struct termios *arg"
31bbf21555SRichard Lowe.Sh DESCRIPTION
32bbf21555SRichard LoweThis release supports a general interface for asynchronous communications ports
33bbf21555SRichard Lowethat is hardware-independent.
34bbf21555SRichard LoweThe user interface to this functionality is using
35bbf21555SRichard Lowefunction calls (the preferred interface) described in
36bbf21555SRichard Lowe.Xr termios 3C
37bbf21555SRichard Loweor
38bbf21555SRichard Lowe.Fn ioctl
39bbf21555SRichard Lowecommands described in this section.
40bbf21555SRichard LoweThis section also discusses the
41bbf21555SRichard Lowecommon features of the terminal subsystem which are relevant with both user
42bbf21555SRichard Loweinterfaces.
43bbf21555SRichard Lowe.Pp
44bbf21555SRichard LoweWhen a terminal file is opened, it normally causes the process to wait until a
45bbf21555SRichard Loweconnection is established.
46bbf21555SRichard LoweIn practice, user programs seldom open terminal
47bbf21555SRichard Lowefiles; they are opened by the system and become a user's standard input,
48bbf21555SRichard Loweoutput, and error files.
49bbf21555SRichard LoweThe first terminal file opened by the session leader
50bbf21555SRichard Lowethat is not already associated with a session becomes the controlling terminal
51bbf21555SRichard Lowefor that session.
52bbf21555SRichard LoweThe controlling terminal plays a special role in handling
53bbf21555SRichard Lowequit and interrupt signals, as discussed below.
54bbf21555SRichard LoweThe controlling terminal is
55bbf21555SRichard Loweinherited by a child process during a
56bbf21555SRichard Lowe.Xr fork 2 .
57bbf21555SRichard LoweA process can break this
58bbf21555SRichard Loweassociation by changing its session using
59bbf21555SRichard Lowe.Xr setsid 2 .
60bbf21555SRichard Lowe.Pp
61bbf21555SRichard LoweA terminal associated with one of these files ordinarily operates in
62bbf21555SRichard Lowefull-duplex mode.
63bbf21555SRichard LoweCharacters may be typed at any time, even while output is
64bbf21555SRichard Loweoccurring, and are only lost when the character input buffers of the system
65bbf21555SRichard Lowebecome completely full, which is rare.
66bbf21555SRichard LoweFor example, the number of characters in
67bbf21555SRichard Lowethe line discipline buffer may exceed
68bbf21555SRichard Lowe.Brq Dv MAX_CANON
69bbf21555SRichard Loweand
70bbf21555SRichard Lowe.Dv IMAXBEL
71bbf21555SRichard Lowe(see below) is not set, or the user may accumulate
72bbf21555SRichard Lowe.Brq Dv MAX_INPUT
73bbf21555SRichard Lowenumber of input characters that have not yet been read by some program.
74bbf21555SRichard LoweWhen the input
75bbf21555SRichard Lowelimit is reached, all the characters saved in the buffer up to that point are
76bbf21555SRichard Lowethrown away without notice.
77bbf21555SRichard Lowe.Ss "Session Management (Job Control)"
78bbf21555SRichard LoweA control terminal will distinguish one of the process groups in the session
79bbf21555SRichard Loweassociated with it to be the foreground process group.
80bbf21555SRichard LoweAll other process
81bbf21555SRichard Lowegroups in the session are designated as background process groups.
82bbf21555SRichard LoweThis foreground process group plays a special role in handling signal-generating
83bbf21555SRichard Loweinput characters, as discussed below.
84bbf21555SRichard LoweBy default, when a controlling terminal
85bbf21555SRichard Loweis allocated, the controlling process's process group is assigned as
86bbf21555SRichard Loweforeground process group.
87bbf21555SRichard Lowe.Pp
88bbf21555SRichard LoweBackground process groups in the controlling process's session are subject to a
89bbf21555SRichard Lowejob control line discipline when they attempt to access their controlling
90bbf21555SRichard Loweterminal.
91bbf21555SRichard LoweProcess groups can be sent signals that will cause them to stop,
92bbf21555SRichard Loweunless they have made other arrangements.
93bbf21555SRichard LoweAn exception is made for members of
94bbf21555SRichard Loweorphaned process groups.
95bbf21555SRichard Lowe.Pp
96bbf21555SRichard LoweAn orphaned process group is one where the process group (see
97bbf21555SRichard Lowe.Xr getpgid 2 )
98bbf21555SRichard Lowehas no members with a parent in a different process group but sharing the same
99bbf21555SRichard Lowecontrolling terminal.
100bbf21555SRichard LoweWhen a member of an orphaned process group attempts to
101bbf21555SRichard Loweaccess its controlling terminal, EIO is returned because there would be no way
102bbf21555SRichard Loweto restart the process if it were stopped on one of these signals.
103bbf21555SRichard Lowe.Pp
104bbf21555SRichard LoweIf a member of a background process group attempts to read its controlling
105bbf21555SRichard Loweterminal, its process group will be sent a
106bbf21555SRichard Lowe.Dv SIGTTIN
107bbf21555SRichard Lowesignal, which will
108bbf21555SRichard Lowenormally cause the members of that process group to stop.
109bbf21555SRichard LoweIf, however, the
110bbf21555SRichard Loweprocess is ignoring or holding
111bbf21555SRichard Lowe.Dv SIGTTIN ,
112bbf21555SRichard Loweor is a member of an orphaned
113bbf21555SRichard Loweprocess group, the read will fail with
114bbf21555SRichard Lowe.Va errno
115bbf21555SRichard Loweset to
116bbf21555SRichard Lowe.Er EIO ,
117bbf21555SRichard Loweand no signal is sent.
118bbf21555SRichard Lowe.Pp
119bbf21555SRichard LoweIf a member of a background process group attempts to write its controlling
120bbf21555SRichard Loweterminal and the
121bbf21555SRichard Lowe.Dv TOSTOP
122bbf21555SRichard Lowebit is set in the
123bbf21555SRichard Lowe.Fa c_lflag
124bbf21555SRichard Lowefield, its process group is sent a
125bbf21555SRichard Lowe.Dv SIGTTOU
126bbf21555SRichard Lowesignal, which will normally cause the
127bbf21555SRichard Lowemembers of that process group to stop.
128bbf21555SRichard LoweIf, however, the process is ignoring or
129bbf21555SRichard Loweholding
130bbf21555SRichard Lowe.Dv SIGTTOU ,
131bbf21555SRichard Lowethe write will succeed.
132bbf21555SRichard LoweIf the process is not ignoring
133bbf21555SRichard Loweor holding
134bbf21555SRichard Lowe.Dv SIGTTOU
135bbf21555SRichard Loweand is a member of an orphaned process group, the
136bbf21555SRichard Lowewrite will fail with
137bbf21555SRichard Lowe.Va errno
138bbf21555SRichard Loweset to
139bbf21555SRichard Lowe.Er EIO ,
140bbf21555SRichard Loweand no signal will be sent.
141bbf21555SRichard Lowe.Pp
142bbf21555SRichard LoweIf
143bbf21555SRichard Lowe.Dv TOSTOP
144bbf21555SRichard Loweis set and a member of a background process group attempts to
145bbf21555SRichard Lowe.Fn ioctl
146bbf21555SRichard Loweits controlling terminal, and that
147bbf21555SRichard Lowe.Fn ioctl
148bbf21555SRichard Lowewill modify terminal parameters (for example,
149bbf21555SRichard Lowe.Dv TCSETA ,
150bbf21555SRichard Lowe.Dv TCSETAW ,
151bbf21555SRichard Lowe.Dv TCSETAF ,
152bbf21555SRichard Loweor
153bbf21555SRichard Lowe.Dv TIOCSPGRP ) ,
154bbf21555SRichard Loweits process group will be sent a
155bbf21555SRichard Lowe.Dv SIGTTOU
156bbf21555SRichard Lowesignal, which will normally cause the members of that process group to stop.
157bbf21555SRichard LoweIf, however, the process is ignoring or holding
158bbf21555SRichard Lowe.Dv SIGTTOU ,
159bbf21555SRichard Lowethe ioctl will succeed.
160bbf21555SRichard LoweIf the process is not ignoring or holding
161bbf21555SRichard Lowe.Dv SIGTTOU
162bbf21555SRichard Loweand is a member of an orphaned
163bbf21555SRichard Loweprocess group, the write will fail with
164bbf21555SRichard Lowe.Va errno
165bbf21555SRichard Loweset to
166bbf21555SRichard Lowe.Er EIO ,
167bbf21555SRichard Loweand no signal will be sent.
168bbf21555SRichard Lowe.Ss "Canonical Mode Input Processing"
169bbf21555SRichard LoweNormally, terminal input is processed in units of lines.
170bbf21555SRichard LoweA line is delimited by
171bbf21555SRichard Lowea newline
172bbf21555SRichard Lowe.Po
173bbf21555SRichard Lowe.Sy ASCII LF
174bbf21555SRichard Lowe.Pc
175bbf21555SRichard Lowecharacter, an end-of-file
176bbf21555SRichard Lowe.Po
177bbf21555SRichard Lowe.Sy ASCII EOT
178bbf21555SRichard Lowe.Pc
179bbf21555SRichard Lowecharacter, or an end-of-line character.
180bbf21555SRichard LoweThis means that a program attempting to
181bbf21555SRichard Loweread will block until an entire line has been typed.
182bbf21555SRichard LoweAlso, no matter how many
183bbf21555SRichard Lowecharacters are requested in the read call, at most one line will be returned.
184bbf21555SRichard LoweIt is not necessary, however, to read a whole line at once; any number of
185bbf21555SRichard Lowecharacters may be requested in a read, even one, without losing information.
186bbf21555SRichard Lowe.Pp
187bbf21555SRichard LoweDuring input, erase, erase2, and kill processing is normally done.
188bbf21555SRichard LoweThe
189bbf21555SRichard Lowe.Sy ERASE
190bbf21555SRichard Loweand
191bbf21555SRichard Lowe.Sy ERASE2
192bbf21555SRichard Lowecharacter (by default, the character
193bbf21555SRichard Lowe.Sy DEL
194bbf21555SRichard Lowefor
195bbf21555SRichard Lowe.Sy ERASE
196bbf21555SRichard Loweand
197bbf21555SRichard Lowe.Sy Control-h
198bbf21555SRichard Lowefor
199bbf21555SRichard Lowe.Sy ERASE2 )
200bbf21555SRichard Loweerases the last character typed.
201bbf21555SRichard LoweThe
202bbf21555SRichard Lowe.Sy WERASE
203bbf21555SRichard Lowecharacter (the character
204bbf21555SRichard Lowe.Sy Control-w )
205bbf21555SRichard Loweerases the
206bbf21555SRichard Lowelast "word" typed in the current input line (but not any preceding spaces or
207bbf21555SRichard Lowetabs).
208bbf21555SRichard LoweA
209bbf21555SRichard Lowe.Dq word
210bbf21555SRichard Loweis defined as a sequence of non-blank characters, with tabs counted as blanks.
211bbf21555SRichard LoweNone of
212bbf21555SRichard Lowe.Sy ERASE
213bbf21555SRichard Loweor
214bbf21555SRichard Lowe.Sy ERASE2
215bbf21555SRichard Loweor
216bbf21555SRichard Lowe.Sy WERASE
217bbf21555SRichard Lowewill erase beyond the beginning of the line.
218bbf21555SRichard LoweThe
219bbf21555SRichard Lowe.Sy KILL
220bbf21555SRichard Lowecharacter (by default,
221bbf21555SRichard Lowethe character
222bbf21555SRichard Lowe.Sy NAK )
223bbf21555SRichard Lowekills (deletes) the entire input line, and optionally
224bbf21555SRichard Loweoutputs a newline character.
225bbf21555SRichard LoweAll these characters operate on a key stroke basis,
226bbf21555SRichard Loweindependent of any backspacing or tabbing that may have been done.
227bbf21555SRichard LoweThe
228bbf21555SRichard Lowe.Sy REPRINT
229bbf21555SRichard Lowecharacter (the character
230bbf21555SRichard Lowe.Sy Control-r )
231bbf21555SRichard Loweprints a newline followed by all characters that have not been read.
232bbf21555SRichard LoweReprinting also occurs automatically if
233bbf21555SRichard Lowecharacters that would normally be erased from the screen are fouled by program
234bbf21555SRichard Loweoutput.
235bbf21555SRichard LoweThe characters are reprinted as if they were being echoed;
236*899b7fc7SPeter Tribbleconsequently, if
237bbf21555SRichard Lowe.Dv ECHO
238bbf21555SRichard Loweis not set, they are not printed.
239bbf21555SRichard Lowe.Pp
240bbf21555SRichard LoweThe
241bbf21555SRichard Lowe.Sy ERASE ,
242bbf21555SRichard Lowe.Sy ERASE2 ,
243bbf21555SRichard Loweand
244bbf21555SRichard Lowe.Sy KILL
245bbf21555SRichard Lowecharacters may be entered literally by preceding them with the escape character.
246bbf21555SRichard LoweIn this case, the escape character is not read.
247bbf21555SRichard LoweThe erase, erase2, and kill characters may be changed.
248bbf21555SRichard Lowe.Ss "Non-canonical Mode Input Processing"
249bbf21555SRichard LoweIn non-canonical mode input processing, input characters are not assembled into
250bbf21555SRichard Lowelines, and erase and kill processing does not occur.
251bbf21555SRichard LoweThe
252bbf21555SRichard Lowe.Sy MIN
253bbf21555SRichard Loweand
254bbf21555SRichard Lowe.Sy TIME
255bbf21555SRichard Lowevalues are used to determine how to process the characters received.
256bbf21555SRichard Lowe.Pp
257bbf21555SRichard Lowe.Sy MIN
258bbf21555SRichard Lowerepresents the minimum number of characters that should be received
259bbf21555SRichard Lowewhen the read is satisfied (that is, when the characters are returned to the
260bbf21555SRichard Loweuser).
261bbf21555SRichard Lowe.Sy TIME
262bbf21555SRichard Loweis a timer of 0\&.10-second granularity that is used to timeout
263bbf21555SRichard Lowebursty and short-term data transmissions.
264bbf21555SRichard LoweThe four possible values for
265bbf21555SRichard Lowe.Sy MIN
266bbf21555SRichard Loweand
267bbf21555SRichard Lowe.Sy TIME
268bbf21555SRichard Loweand their interactions are described below.
269bbf21555SRichard Lowe.Bl -tag -width "Case A: Min > 0, Time > 0"
270bbf21555SRichard Lowe.It Sy Case A: MIN > 0, TIME > 0
271bbf21555SRichard LoweIn this case,
272bbf21555SRichard Lowe.Sy TIME
273bbf21555SRichard Loweserves as an intercharacter timer and is activated
274bbf21555SRichard Loweafter the first character is received.
275bbf21555SRichard LoweSince it is an intercharacter timer, it
276bbf21555SRichard Loweis reset after a character is received.
277bbf21555SRichard LoweThe interaction between
278bbf21555SRichard Lowe.Sy MIN
279bbf21555SRichard Loweand
280bbf21555SRichard Lowe.Sy TIME
281bbf21555SRichard Loweis as follows: as soon as one character is received, the
282bbf21555SRichard Loweintercharacter timer is started.
283bbf21555SRichard LoweIf
284bbf21555SRichard Lowe.Sy MIN
285bbf21555SRichard Lowecharacters are received before
286bbf21555SRichard Lowethe intercharacter timer expires (note that the timer is reset upon receipt of
287bbf21555SRichard Loweeach character), the read is satisfied.
288bbf21555SRichard LoweIf the timer expires before
289bbf21555SRichard Lowe.Sy MIN
290bbf21555SRichard Lowecharacters are received, the characters received to that point are returned to
291bbf21555SRichard Lowethe user.
292bbf21555SRichard LoweNote that if
293bbf21555SRichard Lowe.Sy TIME
294bbf21555SRichard Loweexpires, at least one character will be
295bbf21555SRichard Lowereturned because the timer would not have been enabled unless a character was
296bbf21555SRichard Lowereceived.
297bbf21555SRichard LoweIn this case (MIN > 0, TIME > 0), the read sleeps until the
298bbf21555SRichard Lowe.Sy MIN
299bbf21555SRichard Loweand
300bbf21555SRichard Lowe.Sy TIME
301bbf21555SRichard Lowemechanisms are activated by the receipt of the first character.
302bbf21555SRichard LoweIf the number of characters read is less than the number of characters
303bbf21555SRichard Loweavailable, the timer is not reactivated and the subsequent read is satisfied
304bbf21555SRichard Loweimmediately.
305bbf21555SRichard Lowe.It Sy Case B: MIN > 0, TIME = 0
306bbf21555SRichard LoweIn this case, since the value of
307bbf21555SRichard Lowe.Sy TIME
308bbf21555SRichard Loweis zero, the timer plays no role
309bbf21555SRichard Loweand only
310bbf21555SRichard Lowe.Sy MIN
311bbf21555SRichard Loweis significant.
312bbf21555SRichard LoweA pending read is not satisfied until
313bbf21555SRichard Lowe.Sy MIN
314bbf21555SRichard Lowecharacters are received (the pending read sleeps until
315bbf21555SRichard Lowe.Sy MIN
316bbf21555SRichard Lowecharacters are received).
317bbf21555SRichard LoweA program that uses this case to read record based
318bbf21555SRichard Loweterminal
319bbf21555SRichard Lowe.Sy I/O
320bbf21555SRichard Lowemay block indefinitely in the read operation.
321bbf21555SRichard Lowe.It Sy Case C: MIN = 0, TIME > 0
322bbf21555SRichard LoweIn this case, since
323bbf21555SRichard Lowe.Sy MIN
324bbf21555SRichard Lowe0,
325bbf21555SRichard Lowe.Sy TIME
326bbf21555SRichard Loweno longer represents an
327bbf21555SRichard Loweintercharacter timer: it now serves as a read timer that is activated as soon
328bbf21555SRichard Loweas a
329bbf21555SRichard Lowe.Xr read  2
330bbf21555SRichard Loweis done.
331bbf21555SRichard LoweA read is satisfied as soon as a single character is
332bbf21555SRichard Lowereceived or the read timer expires.
333bbf21555SRichard LoweNote that, in this case, if the timer
334bbf21555SRichard Loweexpires, no character is returned.
335bbf21555SRichard LoweIf the timer does not expire, the only way
336bbf21555SRichard Lowethe read can be satisfied is if a character is received.
337bbf21555SRichard LoweIn this case, the
338bbf21555SRichard Loweread will not block indefinitely waiting for a character; if no character is
339bbf21555SRichard Lowereceived within
340bbf21555SRichard Lowe.Sy TIME
341bbf21555SRichard Lowe*\&.10 seconds after the read is initiated, the read
342bbf21555SRichard Lowereturns with zero characters.
343bbf21555SRichard Lowe.It Sy Case D: MIN = 0, TIME = 0
344bbf21555SRichard LoweIn this case, return is immediate.
345bbf21555SRichard LoweThe minimum of either the number of
346bbf21555SRichard Lowecharacters requested or the number of characters currently available is
347bbf21555SRichard Lowereturned without waiting for more characters to be input.
348bbf21555SRichard Lowe.El
349bbf21555SRichard Lowe.Ss "Comparing Different Cases of MIN, TIME Interaction"
350bbf21555SRichard LoweSome points to note about
351bbf21555SRichard Lowe.Sy MIN
352bbf21555SRichard Loweand
353bbf21555SRichard Lowe.Sy TIME :
354bbf21555SRichard Lowe.Bl -bullet -offset 2n
355bbf21555SRichard Lowe.It
356bbf21555SRichard LoweIn the following explanations, note that the interactions of
357bbf21555SRichard Lowe.Sy MIN
358bbf21555SRichard Loweand
359bbf21555SRichard Lowe.Sy TIME
360bbf21555SRichard Loweare not symmetric.
361bbf21555SRichard LoweFor example, when
362bbf21555SRichard Lowe.Sy MIN
363bbf21555SRichard Lowe> 0 and
364bbf21555SRichard Lowe.Sy TIME
365bbf21555SRichard Lowe= 0,
366bbf21555SRichard Lowe.Sy TIME
367bbf21555SRichard Lowehas no effect.
368bbf21555SRichard LoweHowever, in the opposite case, where
369bbf21555SRichard Lowe.Sy MIN
370bbf21555SRichard Lowe= 0 and
371bbf21555SRichard Lowe.Sy TIME
372bbf21555SRichard Lowe> 0, both
373bbf21555SRichard Lowe.Sy MIN
374bbf21555SRichard Loweand
375bbf21555SRichard Lowe.Sy TIME
376bbf21555SRichard Loweplay a role in that
377bbf21555SRichard Lowe.Sy MIN
378bbf21555SRichard Loweis satisfied with the receipt of a single character.
379bbf21555SRichard Lowe.It
380bbf21555SRichard LoweAlso note that in case A
381bbf21555SRichard Lowe.Po
382bbf21555SRichard Lowe.Sy MIN
383bbf21555SRichard Lowe> 0,
384bbf21555SRichard Lowe.Sy TIME
385bbf21555SRichard Lowe> 0
386bbf21555SRichard Lowe.Pc ,
387bbf21555SRichard Lowe.Sy TIME
388bbf21555SRichard Lowerepresents
389bbf21555SRichard Lowean intercharacter timer, whereas in case C
390bbf21555SRichard Lowe.Po
391bbf21555SRichard Lowe.Sy MIN
392bbf21555SRichard Lowe= 0,
393bbf21555SRichard Lowe.Sy TIME
394bbf21555SRichard Lowe> 0
395bbf21555SRichard Lowe.Pc ,
396bbf21555SRichard Lowe.Sy TIME
397bbf21555SRichard Lowerepresents a read timer.
398bbf21555SRichard Lowe.El
399bbf21555SRichard Lowe.Pp
400bbf21555SRichard LoweThese two points highlight the dual purpose of the
401bbf21555SRichard Lowe.Sy MIN/TIME
402bbf21555SRichard Lowefeature.
403bbf21555SRichard LoweCases A and B, where
404bbf21555SRichard Lowe.Sy MIN
405bbf21555SRichard Lowe> 0, exist to handle burst mode activity (for
406bbf21555SRichard Loweexample, file transfer programs), where a program would like to process at
407bbf21555SRichard Loweleast
408bbf21555SRichard Lowe.Sy MIN
409bbf21555SRichard Lowecharacters at a time.
410*899b7fc7SPeter TribbleIn case A, the intercharacter timer is
411bbf21555SRichard Loweactivated by a user as a safety measure; in case B, the timer is turned off.
412bbf21555SRichard Lowe.Pp
413bbf21555SRichard LoweCases C and D exist to handle single character, timed transfers.
414bbf21555SRichard LoweThese cases
415bbf21555SRichard Loweare readily adaptable to screen-based applications that need to know if a
416bbf21555SRichard Lowecharacter is present in the input queue before refreshing the screen.
417bbf21555SRichard LoweIn case
418bbf21555SRichard LoweC, the read is timed, whereas in case D, it is not.
419bbf21555SRichard Lowe.Pp
420bbf21555SRichard LoweAnother important note is that
421bbf21555SRichard Lowe.Sy MIN
422bbf21555SRichard Loweis always just a minimum.
423bbf21555SRichard LoweIt does not
424bbf21555SRichard Lowedenote a record length.
425bbf21555SRichard LoweFor example, if a program does a read of 20 bytes,
426bbf21555SRichard Lowe.Sy MIN
427bbf21555SRichard Loweis 10, and 25 characters are present, then 20 characters will be
428bbf21555SRichard Lowereturned to the user.
429bbf21555SRichard Lowe.Ss "Writing Characters"
430bbf21555SRichard LoweWhen one or more characters are written, they are transmitted to the terminal
431bbf21555SRichard Loweas soon as previously written characters have finished typing.
432bbf21555SRichard Lowenputt characters
433bbf21555SRichard Loweare echoed as they are typed if echoing has been enabled.
434bbf21555SRichard LoweIf a process produces
435bbf21555SRichard Lowecharacters more rapidly than they can be typed, it will be suspended when its
436bbf21555SRichard Loweoutput queue exceeds some limit.
437bbf21555SRichard LoweWhen the queue is drained down to some
438bbf21555SRichard Lowethreshold, the program is resumed.
439bbf21555SRichard Lowe.Ss "Special Characters"
440bbf21555SRichard LoweCertain characters have special functions on input.
441bbf21555SRichard LoweThese functions and their default character values are summarized as follows:
442bbf21555SRichard Lowe.Bl -tag -width REPRINT
443bbf21555SRichard Lowe.It Sy INTR
444bbf21555SRichard Lowe(Control-c or
445bbf21555SRichard Lowe.Sy ASCII ETX )
446bbf21555SRichard Lowegenerates a
447bbf21555SRichard Lowe.Dv SIGINT
448bbf21555SRichard Lowesignal.
449bbf21555SRichard Lowe.Dv SIGINT
450bbf21555SRichard Loweis sent to all foreground processes associated with the controlling terminal.
451bbf21555SRichard LoweNormally, each such process is forced to terminate, but arrangements may be
452bbf21555SRichard Lowemade either to ignore the signal or to receive a trap to an agreed upon
453bbf21555SRichard Lowelocation.
454bbf21555SRichard Lowe(See
455bbf21555SRichard Lowe.Xr signal.h 3HEAD ) .
456bbf21555SRichard Lowe.It Sy QUIT
457bbf21555SRichard Lowe(Control-| or
458bbf21555SRichard Lowe.Sy ASCII FS )
459bbf21555SRichard Lowegenerates a
460bbf21555SRichard Lowe.Dv SIGQUIT
461bbf21555SRichard Lowesignal.
462bbf21555SRichard LoweIts treatment
463bbf21555SRichard Loweis identical to the interrupt signal except that, unless a receiving process
464bbf21555SRichard Lowehas made other arrangements, it will not only be terminated but a core image
465bbf21555SRichard Lowefile (called
466bbf21555SRichard Lowe.Pa core )
467bbf21555SRichard Lowewill be created in the current working directory.
468bbf21555SRichard Lowe.It Sy ERASE
469bbf21555SRichard Lowe(DEL) erases the preceding character.
470bbf21555SRichard LoweIt does not erase beyond
471bbf21555SRichard Lowethe start of a line, as delimited by a
472bbf21555SRichard Lowe.Sy NL ,
473bbf21555SRichard Lowe.Sy EOF ,
474bbf21555SRichard Lowe.Sy EOL ,
475bbf21555SRichard Loweor
476bbf21555SRichard Lowe.Sy EOL2
477bbf21555SRichard Lowecharacter.
478bbf21555SRichard Lowe.It Sy ERASE2
479bbf21555SRichard Lowe(Control-h or
480bbf21555SRichard Lowe.Sy ASCII BS )
481bbf21555SRichard Loweerases the preceding character, with behaviour identical to that of ERASE.
482bbf21555SRichard Lowe.It Sy WERASE
483bbf21555SRichard Lowe(Control-w or
484bbf21555SRichard Lowe.Sy ASCII ETX )
485bbf21555SRichard Loweerases the preceding
486bbf21555SRichard Lowe.Dq word .
487bbf21555SRichard LoweIt does not erase beyond the start of a line, as delimited by a
488bbf21555SRichard Lowe.Sy NL ,
489bbf21555SRichard Lowe.Sy EOF ,
490bbf21555SRichard Lowe.Sy EOL ,
491bbf21555SRichard Loweor
492bbf21555SRichard Lowe.Sy EOL2
493bbf21555SRichard Lowecharacter.
494bbf21555SRichard Lowe.It Sy KILL
495bbf21555SRichard Lowe(Control-u or
496bbf21555SRichard Lowe.Sy ASCII NAK )
497bbf21555SRichard Lowedeletes the entire line, as delimited by a
498bbf21555SRichard Lowe.Sy NL ,
499bbf21555SRichard Lowe.Sy EOF ,
500bbf21555SRichard Lowe.Sy EOL ,
501bbf21555SRichard Loweor
502bbf21555SRichard Lowe.Sy EOL2
503bbf21555SRichard Lowecharacter.
504bbf21555SRichard Lowe.It Sy REPRINT
505bbf21555SRichard Lowe(Control-r or
506bbf21555SRichard Lowe.Sy ASCII DC2 )
507bbf21555SRichard Lowereprints all characters, preceded by a newline, that have not been read.
508bbf21555SRichard Lowe.It Sy EOF
509bbf21555SRichard Lowe(Control-d or
510bbf21555SRichard Lowe.Sy ASCII EOT )
511bbf21555SRichard Lowemay be used to generate an end-of-file from a terminal.
512bbf21555SRichard LoweWhen received, all the characters waiting to be read are immediately
513bbf21555SRichard Lowepassed to the program, without waiting for a newline, and the
514bbf21555SRichard Lowe.Sy EOF
515bbf21555SRichard Loweis discarded.
516bbf21555SRichard LoweThus, if no characters are waiting (that is, the
517bbf21555SRichard Lowe.Sy EOF
518bbf21555SRichard Loweoccurred
519bbf21555SRichard Loweat the beginning of a line) zero characters are passed back, which is the
520bbf21555SRichard Lowestandard end-of-file indication.
521bbf21555SRichard LoweUnless escaped, the
522bbf21555SRichard Lowe.Sy EOF
523bbf21555SRichard Lowecharacter is not
524bbf21555SRichard Loweechoed.
525bbf21555SRichard LoweBecause
526bbf21555SRichard Lowe.Sy EOT
527bbf21555SRichard Loweis the default
528bbf21555SRichard Lowe.Sy EOF
529bbf21555SRichard Lowecharacter, this prevents
530bbf21555SRichard Loweterminals that respond to
531bbf21555SRichard Lowe.Sy EOT
532bbf21555SRichard Lowefrom hanging up.
533bbf21555SRichard Lowe.It Sy NL
534bbf21555SRichard Lowe.Pq Sy ASCII LF
535bbf21555SRichard Loweis the normal line delimiter.
536bbf21555SRichard LoweIt cannot be changed or escaped.
537bbf21555SRichard Lowe.It Sy EOL
538bbf21555SRichard Lowe.Pq Sy ASCII NULL
539bbf21555SRichard Loweis an additional line delimiter, like
540bbf21555SRichard Lowe.Sy NL .
541bbf21555SRichard LoweIt is not normally used.
542bbf21555SRichard Lowe.It Sy EOL2
543bbf21555SRichard Loweis another additional line delimiter.
544bbf21555SRichard Lowe.It Sy SWTCH
545bbf21555SRichard Lowe(Control-z or
546bbf21555SRichard Lowe.Sy ASCII EM )
547bbf21555SRichard LoweHeader file symbols related to this special
548bbf21555SRichard Lowecharacter are present for compatibility purposes only and the kernel takes no
549bbf21555SRichard Lowespecial action on matching SWTCH (except to discard the character).
550bbf21555SRichard Lowe.It Sy SUSP
551bbf21555SRichard Lowe(Control-z or
552bbf21555SRichard Lowe.Sy ASCII SUB )
553bbf21555SRichard Lowegenerates a
554bbf21555SRichard Lowe.Dv SIGTSTP
555bbf21555SRichard Lowesignal.
556bbf21555SRichard Lowe.Dv SIGTSTP
557bbf21555SRichard Lowestops all processes in the foreground process group for that terminal.
558bbf21555SRichard Lowe.It Sy DSUSP
559bbf21555SRichard Lowe(Control-y or
560bbf21555SRichard Lowe.Sy ASCII EM ) .
561bbf21555SRichard LoweIt generates a
562bbf21555SRichard Lowe.Dv SIGTSTP
563bbf21555SRichard Lowesignal as
564bbf21555SRichard Lowe.Sy SUSP
565bbf21555SRichard Lowedoes, but the signal is sent when a process in the foreground
566bbf21555SRichard Loweprocess group attempts to read the
567bbf21555SRichard Lowe.Sy DSUSP
568bbf21555SRichard Lowecharacter, rather than when it is typed.
569bbf21555SRichard Lowe.It Sy STOP
570bbf21555SRichard Lowe(Control-s or
571bbf21555SRichard Lowe.Sy ASCII DC3 )
572bbf21555SRichard Lowecan be used to suspend output temporarily.
573bbf21555SRichard LoweIt is useful with
574bbf21555SRichard Lowe.Sy CRT
575bbf21555SRichard Loweterminals to prevent output from disappearing before it can be read.
576bbf21555SRichard LoweWhile output is suspended,
577bbf21555SRichard Lowe.Sy STOP
578bbf21555SRichard Lowecharacters are ignored and
579bbf21555SRichard Lowenot read.
580bbf21555SRichard Lowe.It Sy START
581bbf21555SRichard Lowe(Control-q or
582bbf21555SRichard Lowe.Sy ASCII DC1 )
583bbf21555SRichard Loweis used to resume output.
584bbf21555SRichard LoweOutput has been suspended by a
585bbf21555SRichard Lowe.Sy STOP
586bbf21555SRichard Lowecharacter.
587bbf21555SRichard LoweWhile output is not suspended,
588bbf21555SRichard Lowe.Sy START
589bbf21555SRichard Lowecharacters are ignored and not read.
590bbf21555SRichard Lowe.It Sy DISCARD
591bbf21555SRichard Lowe(Control-o or
592bbf21555SRichard Lowe.Sy ASCII SI )
593bbf21555SRichard Lowecauses subsequent output to be discarded.
594bbf21555SRichard LoweOutput is discarded until another
595bbf21555SRichard Lowe.Sy DISCARD
596bbf21555SRichard Lowecharacter is typed, more input
597bbf21555SRichard Lowearrives, or the condition is cleared by a program.
598bbf21555SRichard Lowe.It Sy STATUS
599bbf21555SRichard Lowe(Control-t or
600bbf21555SRichard Lowe.Sy ASCII DC4 )
601bbf21555SRichard Lowegenerates a
602bbf21555SRichard Lowe.Dv SIGINFO
603bbf21555SRichard Lowesignal.
604bbf21555SRichard LoweProcesses with a handler will output status information when they receive
605bbf21555SRichard Lowe.Dv SIGINFO ,
606bbf21555SRichard Lowefor
607bbf21555SRichard Loweexample,
608bbf21555SRichard Lowe.Xr dd 8 .
609bbf21555SRichard LoweIf a process does not have a
610bbf21555SRichard Lowe.Dv SIGINFO
611bbf21555SRichard Lowehandler, the
612bbf21555SRichard Lowesignal will be ignored.
613bbf21555SRichard Lowe.It Sy LNEXT
614bbf21555SRichard Lowe(Control-v or
615bbf21555SRichard Lowe.Sy ASCII SYN )
616bbf21555SRichard Lowecauses the special meaning of the next character to be ignored.
617bbf21555SRichard LoweThis works for all the special characters mentioned above.
618bbf21555SRichard LoweIt
619bbf21555SRichard Loweallows characters to be input that would otherwise be interpreted by the system
620bbf21555SRichard Lowe(for example
621bbf21555SRichard Lowe.Sy KILL ,
622bbf21555SRichard Lowe.Sy QUIT ) .
623bbf21555SRichard LoweThe character values for
624bbf21555SRichard Lowe.Sy INTR ,
625bbf21555SRichard Lowe.Sy QUIT ,
626bbf21555SRichard Lowe.Sy ERASE ,
627bbf21555SRichard Lowe.Sy ERASE2 ,
628bbf21555SRichard Lowe.Sy WERASE ,
629bbf21555SRichard Lowe.Sy KILL ,
630bbf21555SRichard Lowe.Sy REPRINT ,
631bbf21555SRichard Lowe.Sy EOF ,
632bbf21555SRichard Lowe.Sy EOL ,
633bbf21555SRichard Lowe.Sy EOL2 ,
634bbf21555SRichard Lowe.Sy SWTCH ,
635bbf21555SRichard Lowe.Sy SUSP ,
636bbf21555SRichard Lowe.Sy DSUSP ,
637bbf21555SRichard Lowe.Sy STOP ,
638bbf21555SRichard Lowe.Sy START ,
639bbf21555SRichard Lowe.Sy DISCARD ,
640bbf21555SRichard Lowe.Sy STATUS ,
641bbf21555SRichard Loweand
642bbf21555SRichard Lowe.Sy LNEXT
643bbf21555SRichard Lowemay be changed to suit individual tastes.
644bbf21555SRichard LoweIf the value of a special control character
645bbf21555SRichard Loweis
646bbf21555SRichard Lowe.Dv _POSIX_VDISABLE
647bbf21555SRichard Lowe(0), the function of that special control character is disabled.
648bbf21555SRichard LoweThe
649bbf21555SRichard Lowe.Sy ERASE ,
650bbf21555SRichard Lowe.Sy ERASE2 ,
651bbf21555SRichard Lowe.Sy KILL ,
652bbf21555SRichard Loweand
653bbf21555SRichard Lowe.Sy EOF
654bbf21555SRichard Lowecharacters may be
655bbf21555SRichard Loweescaped by a preceding backslash (\e) character, in which case no special
656bbf21555SRichard Lowefunction is done.
657bbf21555SRichard LoweAny of the special characters may be preceded by the
658bbf21555SRichard Lowe.Sy LNEXT
659bbf21555SRichard Lowecharacter, in
660bbf21555SRichard Lowewhich case no special function is done.
661bbf21555SRichard Lowe.El
662bbf21555SRichard Lowe.Ss "Modem Disconnect"
663bbf21555SRichard LoweWhen a modem disconnect is detected, a
664bbf21555SRichard Lowe.Dv SIGHUP
665bbf21555SRichard Lowesignal is sent to the
666bbf21555SRichard Loweterminal's controlling process.
667bbf21555SRichard LoweUnless other arrangements have been made, these
668bbf21555SRichard Lowesignals cause the process to terminate.
669bbf21555SRichard LoweIf
670bbf21555SRichard Lowe.Dv SIGHUP
671bbf21555SRichard Loweis ignored or caught,
672bbf21555SRichard Loweany subsequent read returns with an end-of-file indication until the terminal
673bbf21555SRichard Loweis closed.
674bbf21555SRichard Lowe.Pp
675bbf21555SRichard LoweIf the controlling process is not in the foreground process group of the
676bbf21555SRichard Loweterminal, a
677bbf21555SRichard Lowe.Dv SIGTSTP
678bbf21555SRichard Loweis sent to the terminal's foreground process group.
679bbf21555SRichard LoweUnless other arrangements have been made, these signals cause the processes to
680bbf21555SRichard Lowestop.
681bbf21555SRichard Lowe.Pp
682bbf21555SRichard LoweProcesses in background process groups that attempt to access the controlling
683bbf21555SRichard Loweterminal after modem disconnect while the terminal is still allocated to the
684bbf21555SRichard Lowesession will receive appropriate
685bbf21555SRichard Lowe.Dv SIGTTOU
686bbf21555SRichard Loweand
687bbf21555SRichard Lowe.Dv SIGTTIN
688bbf21555SRichard Lowesignals.
689bbf21555SRichard LoweUnless other arrangements have been made, this signal causes the processes to
690bbf21555SRichard Lowestop.
691bbf21555SRichard Lowe.Pp
692bbf21555SRichard LoweThe controlling terminal will remain in this state until it is reinitialized
693bbf21555SRichard Loweithh a successful open by the controlling process, or deallocated by the
694bbf21555SRichard Lowecontrolling process.
695bbf21555SRichard Lowe.Ss "Terminal Parameters"
696bbf21555SRichard LoweThe parameters that control the behavior of devices and modules providing the
697bbf21555SRichard Lowe.Vt termios
698bbf21555SRichard Loweinterface are specified by the
699bbf21555SRichard Lowe.Vt termios
700bbf21555SRichard Lowestructure defined by
701bbf21555SRichard Lowe.In termios.h .
702bbf21555SRichard LoweSeveral
703bbf21555SRichard Lowe.Xr ioctl 2
704bbf21555SRichard Lowesystem calls that fetch or change
705bbf21555SRichard Lowethese parameters use this structure that contains the following members:
706bbf21555SRichard Lowe.Bd -literal -offset 2n
707bbf21555SRichard Lowetcflag_t	c_iflag;	/* input modes */
708bbf21555SRichard Lowetcflag_t	c_oflag;	/* output modes */
709bbf21555SRichard Lowetcflag_t	c_cflag;	/* control modes */
710bbf21555SRichard Lowetcflag_t	c_lflag;	/* local modes */
711bbf21555SRichard Lowecc_t		c_cc[NCCS];	/* control chars */
712bbf21555SRichard Lowe.Ed
713bbf21555SRichard Lowe.Pp
714bbf21555SRichard LoweThe special control characters are defined by the array
715bbf21555SRichard Lowe.Fa c_cc .
716bbf21555SRichard LoweThe symbolic name
717bbf21555SRichard Lowe.Dv NCCS
718bbf21555SRichard Loweis the size of the Control-character array and is also
719bbf21555SRichard Lowedefined by
720bbf21555SRichard Lowe.In termios.h .
721bbf21555SRichard LoweThe relative positions, subscript names, and
722bbf21555SRichard Lowetypical default values for each function are as follows:
723bbf21555SRichard Lowe.Bl -column "Relative Position" "Subscript Name" "Typical Default Value"
724bbf21555SRichard Lowe.It Relative Position Ta Subscript Name Ta Typical Default Value
725bbf21555SRichard Lowe.It 0 Ta Dv VINTR Ta Sy ETX
726bbf21555SRichard Lowe.It 1 Ta Dv VQUIT Ta Sy FS
727bbf21555SRichard Lowe.It 2 Ta Dv VERASE Ta Sy DEL
728bbf21555SRichard Lowe.It 3 Ta Dv VKILL Ta Sy NAK
729bbf21555SRichard Lowe.It 4 Ta Dv VEOF Ta Sy EOT
730bbf21555SRichard Lowe.It 5 Ta Dv VEOL Ta Sy NUL
731bbf21555SRichard Lowe.It 6 Ta Dv VEOL2 Ta Sy NUL
732bbf21555SRichard Lowe.It 7 Ta Dv VWSTCH Ta Sy NUL
733bbf21555SRichard Lowe.It 8 Ta Dv VSTART Ta Sy NUL
734bbf21555SRichard Lowe.It 9 Ta Dv VSTOP Ta Sy DC3
735bbf21555SRichard Lowe.It 10 Ta Dv VSUSP Ta Sy SUB
736bbf21555SRichard Lowe.It 11 Ta Dv VDSUSP Ta Sy EM
737bbf21555SRichard Lowe.It 12 Ta Dv VREPRINT Ta Sy DC2
738bbf21555SRichard Lowe.It 13 Ta Dv VDISCARD Ta Sy SI
739bbf21555SRichard Lowe.It 14 Ta Dv VWERASE Ta Sy ETB
740bbf21555SRichard Lowe.It 15 Ta Dv VLNEXT Ta Sy SYN
741bbf21555SRichard Lowe.It 16 Ta Dv VSTATUS Ta Sy DC4
742bbf21555SRichard Lowe.It 17 Ta Dv VERASE2 Ta Sy BS
743bbf21555SRichard Lowe.It 18-19 Ta Reserved Ta
744bbf21555SRichard Lowe.El
745bbf21555SRichard Lowe.Ss "Input Modes"
746bbf21555SRichard LoweThe
747bbf21555SRichard Lowe.Fa c_iflag
748bbf21555SRichard Lowefield describes the basic terminal input control:
749bbf21555SRichard Lowe.Pp
750bbf21555SRichard Lowe.Bl -tag -width "IMAXBEL" -offset 2n -compact
751bbf21555SRichard Lowe.It Dv IGNBRK
752bbf21555SRichard LoweIgnore break condition.
753bbf21555SRichard Lowe.It Dv BRKINT
754bbf21555SRichard LoweSignal interrupt on break.
755bbf21555SRichard Lowe.It Dv IGNPAR
756bbf21555SRichard LoweIgnore characters with parity errors.
757bbf21555SRichard Lowe.It Dv PARMRK
758bbf21555SRichard LoweMark parity errors.
759bbf21555SRichard Lowe.It Dv INPCK
760bbf21555SRichard LoweEnable input parity check.
761bbf21555SRichard Lowe.It Dv ISTRIP
762bbf21555SRichard LoweStrip character.
763bbf21555SRichard Lowe.It Dv INLCR
764bbf21555SRichard LoweMap NL to CR on input.
765bbf21555SRichard Lowe.It Dv IGNCR
766bbf21555SRichard LoweIgnore CR.
767bbf21555SRichard Lowe.It Dv ICRNL
768bbf21555SRichard LoweMap CR to NL on input.
769bbf21555SRichard Lowe.It Dv IUCLC
770bbf21555SRichard LoweMap upper-case to lower-case on input.
771bbf21555SRichard Lowe.It Dv IXON
772bbf21555SRichard LoweEnable start/stop output control.
773bbf21555SRichard Lowe.It Dv IXANY
774bbf21555SRichard LoweEnable any character to restart output.
775bbf21555SRichard Lowe.It Dv IXOFF
776bbf21555SRichard LoweEnable start/stop input control.
777bbf21555SRichard Lowe.It Dv IMAXBEL
778bbf21555SRichard LoweEcho
779bbf21555SRichard Lowe.Sy BEL
780bbf21555SRichard Loweon input line too long.
781bbf21555SRichard Lowe.El
782bbf21555SRichard Lowe.Pp
783bbf21555SRichard LoweIf
784bbf21555SRichard Lowe.Dv IGNBRK
785bbf21555SRichard Loweis set, a break condition (a character framing error with data
786bbf21555SRichard Loweall zeros) detected on input is ignored, that is, not put on the input queue
787bbf21555SRichard Loweand therefore not read by any process.
788bbf21555SRichard LoweIf
789bbf21555SRichard Lowe.Dv IGNBRK
790bbf21555SRichard Loweis not set and
791bbf21555SRichard Lowe.Dv BRKINT
792bbf21555SRichard Loweis set, the break condition shall flush the input and output
793bbf21555SRichard Lowequeues and if the terminal is the controlling terminal of a foreground process
794bbf21555SRichard Lowegroup, the break condition generates a single
795bbf21555SRichard Lowe.Dv SIGINT
796bbf21555SRichard Lowesignal to that
797bbf21555SRichard Loweforeground process group.
798bbf21555SRichard LoweIf neither
799bbf21555SRichard Lowe.Dv IGNBRK
800bbf21555SRichard Lowenor
801bbf21555SRichard Lowe.Dv BRKINT
802bbf21555SRichard Loweis set, a
803bbf21555SRichard Lowebreak condition is read as a single
804bbf21555SRichard Lowe.Ql \e0
805bbf21555SRichard Lowe.Pq Sy ASCII NULL
806bbf21555SRichard Lowecharacter, or if
807bbf21555SRichard Lowe.Dv PARMRK
808bbf21555SRichard Loweis set, as
809bbf21555SRichard Lowe.Ql \e377 ,
810bbf21555SRichard Lowe.Ql \e0 ,
811bbf21555SRichard Lowe.Em c ,
812bbf21555SRichard Lowewhere
813bbf21555SRichard Lowe.Ql \e377
814bbf21555SRichard Loweis a single character
815bbf21555SRichard Lowewith value 377 octal (0xff hex, 255 decimal),
816bbf21555SRichard Lowe.Ql \e0
817bbf21555SRichard Loweis a single character with value
818bbf21555SRichard Lowe.Sy 0 ,
819bbf21555SRichard Loweand
820bbf21555SRichard Lowe.Em c
821bbf21555SRichard Loweis the errored character received.
822bbf21555SRichard Lowe.Pp
823bbf21555SRichard LoweIf
824bbf21555SRichard Lowe.Dv IGNPAR
825bbf21555SRichard Loweis set, a byte with framing or parity errors (other than
826bbf21555SRichard Lowebreak) is ignored.
827bbf21555SRichard Lowe.Pp
828bbf21555SRichard LoweIf
829bbf21555SRichard Lowe.Dv PARMRK
830bbf21555SRichard Loweis set, and
831bbf21555SRichard Lowe.Dv IGNPAR
832bbf21555SRichard Loweis not set, a byte with a framing or
833bbf21555SRichard Loweparity error (other than break) is given to the application as the
834bbf21555SRichard Lowethree-character sequence:
835bbf21555SRichard Lowe.Ql \e377 ,
836bbf21555SRichard Lowe.Ql \e0 ,
837bbf21555SRichard Lowec, where
838bbf21555SRichard Lowe.Ql \e377
839bbf21555SRichard Loweis a single character with value 377 octal (0xff hex, 255 decimal),
840bbf21555SRichard Lowe.Ql \e0
841bbf21555SRichard Loweis a single character with value 0, and c is the errored character received.
842bbf21555SRichard LoweTo avoid ambiguity in this case, if
843bbf21555SRichard Lowe.Dv ISTRIP
844bbf21555SRichard Loweis not set, a valid character
845bbf21555SRichard Loweof
846bbf21555SRichard Lowe.Ql \e377
847bbf21555SRichard Loweis given to the application as
848bbf21555SRichard Lowe.Ql \e377 .
849bbf21555SRichard LoweIf neither
850bbf21555SRichard Lowe.Dv IGNPAR
851bbf21555SRichard Lowenor
852bbf21555SRichard Lowe.Dv PARMRK
853bbf21555SRichard Loweis set, a framing or parity error (other than break) is given to
854bbf21555SRichard Lowethe application as a single
855bbf21555SRichard Lowe.Ql \e0
856bbf21555SRichard Lowe.Po
857bbf21555SRichard Lowe.Sy ASCII NULL
858bbf21555SRichard Lowe.Pc
859bbf21555SRichard Lowecharacter.
860bbf21555SRichard Lowe.Pp
861bbf21555SRichard LoweIf
862bbf21555SRichard Lowe.Dv INPCK
863bbf21555SRichard Loweis set, input parity checking is enabled.
864bbf21555SRichard LoweIf
865bbf21555SRichard Lowe.Dv INPCK
866bbf21555SRichard Loweis not
867bbf21555SRichard Loweset, input parity checking is disabled.
868bbf21555SRichard LoweThis allows output parity generation
869bbf21555SRichard Lowewithout input parity errors.
870bbf21555SRichard LoweNote that whether input parity checking is
871bbf21555SRichard Loweenabled or disabled is independent of whether parity detection is enabled or
872bbf21555SRichard Lowedisabled.
873bbf21555SRichard LoweIf parity detection is enabled but input parity checking is
874bbf21555SRichard Lowedisabled, the hardware to which the terminal is connected will recognize the
875bbf21555SRichard Loweparity bit, but the terminal special file will not check whether this is set
876bbf21555SRichard Lowecorrectly or not.
877bbf21555SRichard Lowe.Pp
878bbf21555SRichard LoweIf
879bbf21555SRichard Lowe.Dv ISTRIP
880bbf21555SRichard Loweis set, valid input characters are first stripped to seven
881bbf21555SRichard Lowebits, otherwise all eight bits are processed.
882bbf21555SRichard Lowe.Pp
883bbf21555SRichard LoweIf
884bbf21555SRichard Lowe.Dv INLCR
885bbf21555SRichard Loweis set, a received
886bbf21555SRichard Lowe.Sy NL
887bbf21555SRichard Lowecharacter is translated into a
888bbf21555SRichard Lowe.Sy CR
889bbf21555SRichard Lowecharacter.
890bbf21555SRichard LoweIf
891bbf21555SRichard Lowe.Dv IGNCR
892bbf21555SRichard Loweis set, a received
893bbf21555SRichard Lowe.Sy CR
894bbf21555SRichard Lowecharacter is ignored (not read).
895bbf21555SRichard LoweOtherwise, if
896bbf21555SRichard Lowe.Dv ICRNL
897bbf21555SRichard Loweis set, a received
898bbf21555SRichard Lowe.Sy CR
899bbf21555SRichard Lowecharacter is translated into a
900bbf21555SRichard Lowe.Sy NL
901bbf21555SRichard Lowecharacter.
902bbf21555SRichard Lowe.Pp
903bbf21555SRichard LoweIf
904bbf21555SRichard Lowe.Dv IUCLC
905bbf21555SRichard Loweis set, a received upper case, alphabetic character is
906bbf21555SRichard Lowetranslated into the corresponding lower case character.
907bbf21555SRichard Lowe.Pp
908bbf21555SRichard LoweIf
909bbf21555SRichard Lowe.Dv IXON
910bbf21555SRichard Loweis set, start/stop output control is enabled.
911bbf21555SRichard LoweA received
912bbf21555SRichard Lowe.Sy STOP
913bbf21555SRichard Lowecharacter suspends output and a received
914bbf21555SRichard Lowe.Sy START
915bbf21555SRichard Lowecharacter
916bbf21555SRichard Lowerestarts output.
917bbf21555SRichard LoweThe
918bbf21555SRichard Lowe.Sy STOP
919bbf21555SRichard Loweand
920bbf21555SRichard Lowe.Sy START
921bbf21555SRichard Lowecharacters will not be read,
922bbf21555SRichard Lowebut will merely perform flow control functions.
923bbf21555SRichard LoweIf
924bbf21555SRichard Lowe.Dv IXANY
925bbf21555SRichard Loweis set, any
926bbf21555SRichard Loweinput character restarts output that has been suspended.
927bbf21555SRichard Lowe.Pp
928bbf21555SRichard LoweIf
929bbf21555SRichard Lowe.Dv IXOFF
930bbf21555SRichard Loweis set, the system transmits a
931bbf21555SRichard Lowe.Sy STOP
932bbf21555SRichard Lowecharacter when the
933bbf21555SRichard Loweinput queue is nearly full, and a
934bbf21555SRichard Lowe.Sy START
935bbf21555SRichard Lowecharacter when enough input has
936bbf21555SRichard Lowebeen read so that the input queue is nearly empty again.
937bbf21555SRichard Lowe.Pp
938bbf21555SRichard LoweIf
939bbf21555SRichard Lowe.Dv IMAXBEL
940bbf21555SRichard Loweis set, the
941bbf21555SRichard Lowe.Sy ASCII BEL
942bbf21555SRichard Lowecharacter is echoed if the input stream overflows.
943bbf21555SRichard LoweFurther input is not stored, but any input already present in
944bbf21555SRichard Lowethe input stream is not disturbed.
945bbf21555SRichard LoweIf
946bbf21555SRichard Lowe.Dv IMAXBEL
947bbf21555SRichard Loweis not set, no
948bbf21555SRichard Lowe.Sy BEL
949bbf21555SRichard Lowecharacter is echoed, and all input present in the input queue is discarded if
950bbf21555SRichard Lowethe input stream overflows.
951bbf21555SRichard Lowe.Ss "Output Modes"
952bbf21555SRichard LoweThe
953bbf21555SRichard Lowe.Fa c_oflag
954bbf21555SRichard Lowefield specifies the system treatment of output:
955bbf21555SRichard Lowe.Pp
956bbf21555SRichard Lowe.Bl -tag -width ONLRET -offset 2n -compact
957bbf21555SRichard Lowe.It Dv OPOST
958bbf21555SRichard LowePost-process output.
959bbf21555SRichard Lowe.It Dv OLCUC
960bbf21555SRichard LoweMap lower case to upper on output.
961bbf21555SRichard Lowe.It Dv ONLCR
962bbf21555SRichard LoweMap NL to CR-NL on output.
963bbf21555SRichard Lowe.It Dv OCRNL
964bbf21555SRichard LoweMap CR to NL on output.
965bbf21555SRichard Lowe.It Dv ONOCR
966bbf21555SRichard LoweNo
967bbf21555SRichard Lowe.Sy CR
968bbf21555SRichard Loweoutput at column 0.
969bbf21555SRichard Lowe.It Dv ONLRET
970bbf21555SRichard Lowe.Sy NL
971bbf21555SRichard Loweperforms
972bbf21555SRichard Lowe.Sy CR
973bbf21555SRichard Lowefunction.
974bbf21555SRichard Lowe.It Dv OFILL
975bbf21555SRichard LoweUse fill characters for delay.
976bbf21555SRichard Lowe.It Dv OFDEL
977bbf21555SRichard LoweFill is
978bbf21555SRichard Lowe.Sy DEL ,
979bbf21555SRichard Loweelse
980bbf21555SRichard Lowe.Sy INULL .
981bbf21555SRichard Lowe.It Dv NLDLY
982bbf21555SRichard LoweSelect newline delays:
983bbf21555SRichard Lowe.Bl -tag -width NL0 -compact -offset 2n
984bbf21555SRichard Lowe.It Sy NL0
985bbf21555SRichard Lowe.It Sy NL1
986bbf21555SRichard Lowe.El
987bbf21555SRichard Lowe.It Dv CRDLY
988bbf21555SRichard LoweSelect carriage-return delays:
989bbf21555SRichard Lowe.Bl -tag -width CR0 -compact -offset 2n
990bbf21555SRichard Lowe.It Dv CR0
991bbf21555SRichard Lowe.It Dv CR1
992bbf21555SRichard Lowe.It Dv CR2
993bbf21555SRichard Lowe.It Dv CR3
994bbf21555SRichard Lowe.El
995bbf21555SRichard Lowe.It Dv TABDLY
996bbf21555SRichard LoweSelect horizontal tab delays or tab expansion:
997bbf21555SRichard Lowe.Bl -tag -width XTABS -compact -offset 2n
998bbf21555SRichard Lowe.It Dv TAB0
999bbf21555SRichard Lowe.It Dv TAB1
1000bbf21555SRichard Lowe.It Dv TAB2
1001bbf21555SRichard Lowe.It Dv TAB3
1002bbf21555SRichard LoweExpand tabs to spaces
1003bbf21555SRichard Lowe.It Dv XTABS
1004bbf21555SRichard LoweExpand tabs to spaces
1005bbf21555SRichard Lowe.El
1006bbf21555SRichard Lowe.It Dv BSDLY
1007bbf21555SRichard LoweSelect backspace delays:
1008bbf21555SRichard Lowe.Bl -tag -width BS0 -offset 2n -compact
1009bbf21555SRichard Lowe.It Dv BS0
1010bbf21555SRichard Lowe.It Dv BS1
1011bbf21555SRichard Lowe.El
1012bbf21555SRichard Lowe.It Dv VTDLY
1013bbf21555SRichard LoweSelect vertical tab delays:
1014bbf21555SRichard Lowe.Bl -tag -width VT0 -offset 2n -compact
1015bbf21555SRichard Lowe.It Dv VT0
1016bbf21555SRichard Lowe.It Dv VT1
1017bbf21555SRichard Lowe.El
1018bbf21555SRichard Lowe.It Dv FFDLY
1019bbf21555SRichard LoweSelect form feed delays:
1020bbf21555SRichard Lowe.Bl -tag -width FF0 -offset 2n -compact
1021bbf21555SRichard Lowe.It Dv FF0
1022bbf21555SRichard Lowe.It Dv FF1
1023bbf21555SRichard Lowe.El
1024bbf21555SRichard Lowe.El
1025bbf21555SRichard Lowe.Pp
1026bbf21555SRichard LoweIf
1027bbf21555SRichard Lowe.Dv OPOST
1028bbf21555SRichard Loweis set, output characters are post-processed as indicated by the
1029bbf21555SRichard Loweremaining flags; otherwise, characters are transmitted without change.
1030bbf21555SRichard Lowe.Pp
1031bbf21555SRichard LoweIf
1032bbf21555SRichard Lowe.Dv OLCUC
1033bbf21555SRichard Loweis set, a lower case alphabetic character is transmitted as the
1034bbf21555SRichard Lowecorresponding upper case character.
1035bbf21555SRichard LoweThis function is often used in conjunction
1036bbf21555SRichard Lowewith
1037bbf21555SRichard Lowe.Dv IUCLC .
1038bbf21555SRichard Lowe.Pp
1039bbf21555SRichard LoweIf
1040bbf21555SRichard Lowe.Dv ONLCR
1041bbf21555SRichard Loweis set, the
1042bbf21555SRichard Lowe.Sy NL
1043bbf21555SRichard Lowecharacter is transmitted as the
1044bbf21555SRichard Lowe.Sy CR-NL
1045bbf21555SRichard Lowecharacter pair.
1046bbf21555SRichard LoweIf
1047bbf21555SRichard Lowe.Dv OCRNL
1048bbf21555SRichard Loweis set, the
1049bbf21555SRichard Lowe.Sy CR
1050bbf21555SRichard Lowecharacter is transmitted as the
1051bbf21555SRichard Lowe.Sy NL
1052bbf21555SRichard Lowecharacter.
1053bbf21555SRichard LoweIf
1054bbf21555SRichard Lowe.Dv ONOCR
1055bbf21555SRichard Loweis set, no
1056bbf21555SRichard Lowe.Sy CR
1057bbf21555SRichard Lowecharacter is transmitted when at column 0 (first position).
1058bbf21555SRichard LoweIf
1059bbf21555SRichard Lowe.Dv ONRET
1060bbf21555SRichard Loweis set, the
1061bbf21555SRichard Lowe.Sy NL
1062bbf21555SRichard Lowecharacter is assumed to do the carriage-return function; the column
1063bbf21555SRichard Lowepointer is set to 0 and the delays specified for
1064bbf21555SRichard Lowe.Sy CR
1065bbf21555SRichard Loweare used.
1066bbf21555SRichard LoweOtherwise, the
1067bbf21555SRichard Lowe.Sy NL
1068bbf21555SRichard Lowecharacter is assumed to do just the line-feed function; the column
1069bbf21555SRichard Lowepointer remains unchanged.
1070bbf21555SRichard LoweThe column pointer is also set to 0 if the
1071bbf21555SRichard Lowe.Sy CR
1072bbf21555SRichard Lowecharacter is actually transmitted.
1073bbf21555SRichard Lowe.Pp
1074bbf21555SRichard LoweThe delay bits specify how long transmission stops to allow for mechanical or
1075bbf21555SRichard Loweother movement when certain characters are sent to the terminal.
1076bbf21555SRichard LoweIn all cases, a value of 0 indicates no delay.
1077bbf21555SRichard LoweIf
1078bbf21555SRichard Lowe.Dv OFILL
1079bbf21555SRichard Loweis set, fill characters are transmitted for delay instead of a timed delay.
1080bbf21555SRichard LoweThis is useful for high baud rate terminals that need only a minimal delay.
1081bbf21555SRichard LoweIf
1082bbf21555SRichard Lowe.Dv OFDEL
1083bbf21555SRichard Loweis set, the
1084bbf21555SRichard Lowefill character is
1085bbf21555SRichard Lowe.Sy DEL ;
1086bbf21555SRichard Loweotherwise it is
1087bbf21555SRichard Lowe.Sy NULL .
1088bbf21555SRichard Lowe.Pp
1089bbf21555SRichard LoweIf a form-feed or vertical-tab delay is specified, it lasts for about 2
1090bbf21555SRichard Loweseconds.
1091bbf21555SRichard Lowe.Pp
1092bbf21555SRichard LoweNewline delay lasts about 0\&.10 seconds.
1093bbf21555SRichard LoweIf
1094bbf21555SRichard Lowe.Dv ONLRET
1095bbf21555SRichard Loweis set, the carriage-return delays are used instead of the newline delays.
1096bbf21555SRichard LoweIf
1097bbf21555SRichard Lowe.Dv OFILL
1098bbf21555SRichard Loweis set, two fill characters are transmitted.
1099bbf21555SRichard Lowe.Pp
1100bbf21555SRichard LoweCarriage-return delay type 1 is dependent on the current column position, type
1101bbf21555SRichard Lowe2 is about 0\&.10 seconds, and type 3 is about 0\&.15 seconds.
1102bbf21555SRichard LoweIf
1103bbf21555SRichard Lowe.Dv OFILL
1104bbf21555SRichard Loweis set, delay type 1 transmits two fill characters, and type 2 transmits four
1105bbf21555SRichard Lowefill characters.
1106bbf21555SRichard Lowe.Pp
1107bbf21555SRichard LoweHorizontal-tab delay type 1 is dependent on the current column position.
1108bbf21555SRichard LoweType 2 is about 0\&.10 seconds.
1109bbf21555SRichard LoweType 3 specifies that tabs are to be expanded into spaces.
1110bbf21555SRichard LoweIf
1111bbf21555SRichard Lowe.Dv OFILL
1112bbf21555SRichard Loweis set, two fill characters are transmitted for any delay.
1113bbf21555SRichard Lowe.Pp
1114bbf21555SRichard LoweBackspace delay lasts about 0\&.05 seconds.
1115bbf21555SRichard LoweIf
1116bbf21555SRichard Lowe.Dv OFILL
1117bbf21555SRichard Loweis set, one fill character is transmitted.
1118bbf21555SRichard Lowe.Pp
1119bbf21555SRichard LoweThe actual delays depend on line speed and system load.
1120bbf21555SRichard Lowe.Ss "Control Modes"
1121bbf21555SRichard LoweThe
1122bbf21555SRichard Lowe.Fa c_cflag
1123bbf21555SRichard Lowefield describes the hardware control of the terminal:
1124bbf21555SRichard Lowe.Bl -tag -width CIBAUDEXT -offset 2n
1125bbf21555SRichard Lowe.It Dv CBAUD
1126bbf21555SRichard LoweBaud rate:
1127bbf21555SRichard Lowe.Bl -tag -width B4000000 -compact
1128bbf21555SRichard Lowe.It Dv B0
1129bbf21555SRichard LoweHang up
1130bbf21555SRichard Lowe.It Dv B50
1131bbf21555SRichard Lowe50 baud
1132bbf21555SRichard Lowe.It Dv B75
1133bbf21555SRichard Lowe75 baud
1134bbf21555SRichard Lowe.It Dv B110
1135bbf21555SRichard Lowe110 baud
1136bbf21555SRichard Lowe.It Dv B134
1137bbf21555SRichard Lowe134 baud
1138bbf21555SRichard Lowe.It Dv B150
1139bbf21555SRichard Lowe150 baud
1140bbf21555SRichard Lowe.It Dv B200
1141bbf21555SRichard Lowe200 baud
1142bbf21555SRichard Lowe.It Dv B300
1143bbf21555SRichard Lowe300 baud
1144bbf21555SRichard Lowe.It Dv B600
1145bbf21555SRichard Lowe600 baud
1146bbf21555SRichard Lowe.It Dv B1200
1147bbf21555SRichard Lowe1200 baud
1148bbf21555SRichard Lowe.It Dv B1800
1149bbf21555SRichard Lowe1800 baud
1150bbf21555SRichard Lowe.It Dv B2400
1151bbf21555SRichard Lowe2400 baud
1152bbf21555SRichard Lowe.It Dv B4800
1153bbf21555SRichard Lowe4800 baud
1154bbf21555SRichard Lowe.It Dv B9600
1155bbf21555SRichard Lowe9600 baud
1156bbf21555SRichard Lowe.It Dv B19200
1157bbf21555SRichard Lowe19200 baud
1158bbf21555SRichard Lowe.It Dv B38400
1159bbf21555SRichard Lowe38400 baud
1160bbf21555SRichard Lowe.It Dv B57600
1161bbf21555SRichard Lowe57600 baud
1162bbf21555SRichard Lowe.It Dv B76800
1163bbf21555SRichard Lowe76800 baud
1164bbf21555SRichard Lowe.It Dv B115200
1165bbf21555SRichard Lowe115200 baud
1166bbf21555SRichard Lowe.It Dv B153600
1167bbf21555SRichard Lowe153600 baud
1168bbf21555SRichard Lowe.It Dv B230400
1169bbf21555SRichard Lowe230400 baud
1170bbf21555SRichard Lowe.It Dv B307200
1171bbf21555SRichard Lowe307200 baud
1172bbf21555SRichard Lowe.It Dv B460800
1173bbf21555SRichard Lowe460800 baud
1174bbf21555SRichard Lowe.It Dv B921600
1175bbf21555SRichard Lowe921600 baud
1176bbf21555SRichard Lowe.It Dv B1000000
1177bbf21555SRichard Lowe1000000 baud
1178bbf21555SRichard Lowe.It Dv B1152000
1179bbf21555SRichard Lowe1152000 baud
1180bbf21555SRichard Lowe.It Dv B1500000
1181bbf21555SRichard Lowe1500000 baud
1182bbf21555SRichard Lowe.It Dv B2000000
1183bbf21555SRichard Lowe2000000 baud
1184bbf21555SRichard Lowe.It Dv B2500000
1185bbf21555SRichard Lowe2500000 baud
1186bbf21555SRichard Lowe.It Dv B3000000
1187bbf21555SRichard Lowe3000000 baud
1188bbf21555SRichard Lowe.It Dv B3500000
1189bbf21555SRichard Lowe3500000 baud
1190bbf21555SRichard Lowe.It Dv B4000000
1191bbf21555SRichard Lowe4000000 baud
1192bbf21555SRichard Lowe.El
1193bbf21555SRichard Lowe.It Dv CSIZE
1194bbf21555SRichard LoweCharacter size:
1195bbf21555SRichard Lowe.Bl -tag -width CIBAUDEXT -compact
1196bbf21555SRichard Lowe.It Dv CS5
1197bbf21555SRichard Lowe5 bits
1198bbf21555SRichard Lowe.It Dv CS6
1199bbf21555SRichard Lowe6 bits
1200bbf21555SRichard Lowe.It Dv CS7
1201bbf21555SRichard Lowe7 bits
1202bbf21555SRichard Lowe.It Dv CS8
1203bbf21555SRichard Lowe8 bits
1204bbf21555SRichard Lowe.It Dv CSTOPB
1205bbf21555SRichard LoweSend two stop bits, else one
1206bbf21555SRichard Lowe.It Dv CREAD
1207bbf21555SRichard LoweEnable receiver
1208bbf21555SRichard Lowe.It Dv PARENB
1209bbf21555SRichard LoweParity enable
1210bbf21555SRichard Lowe.It Dv PARODD
1211bbf21555SRichard LoweOdd parity, else even
1212bbf21555SRichard Lowe.It Dv HUPCL
1213bbf21555SRichard LoweHang up on last close
1214bbf21555SRichard Lowe.It Dv CLOCAL
1215bbf21555SRichard LoweLocal line, else dial-up
1216bbf21555SRichard Lowe.It Dv CIBAUD
1217bbf21555SRichard LoweInput baud rate, if different from output rate
1218bbf21555SRichard Lowe.It Dv PAREXT
1219bbf21555SRichard LoweExtended parity for mark and space parity
1220bbf21555SRichard Lowe.It Dv CRTSXOFF
1221bbf21555SRichard LoweEnable inbound hardware flow control
1222bbf21555SRichard Lowe.It Dv CRTSCTS
1223bbf21555SRichard LoweEnable outbound hardware flow control
1224bbf21555SRichard Lowe.It Dv CBAUDEXT
1225bbf21555SRichard LoweBit to indicate output speed > B38400
1226bbf21555SRichard Lowe.It Dv CIBAUDEXT
1227bbf21555SRichard LoweBit to indicate input speed > B38400
1228bbf21555SRichard Lowe.El
1229bbf21555SRichard Lowe.El
1230bbf21555SRichard Lowe.Pp
1231bbf21555SRichard LoweThe
1232bbf21555SRichard Lowe.Dv CBAUD
1233bbf21555SRichard Lowebits together with the
1234bbf21555SRichard Lowe.Dv CBAUDEXT
1235bbf21555SRichard Lowebit specify the output baud rate.
1236bbf21555SRichard LoweTo retrieve the output speed from the
1237bbf21555SRichard Lowe.Vt termios
1238bbf21555SRichard Lowestructure pointed to by
1239bbf21555SRichard Lowe.Fa termios_p
1240bbf21555SRichard Lowesee the following code segment.
1241bbf21555SRichard Lowe.Bd -literal -offset 2n
1242bbf21555SRichard Lowespeed_t ospeed;
1243bbf21555SRichard Loweif (termios_p->c_cflag & CBAUDEXT)
1244bbf21555SRichard Lowe ospeed = (termios_p->c_cflag & CBAUD) + CBAUD + 1;
1245bbf21555SRichard Loweelse
1246bbf21555SRichard Lowe ospeed = termios_p->c_cflag & CBAUD;
1247bbf21555SRichard Lowe.Ed
1248bbf21555SRichard Lowe.Pp
1249bbf21555SRichard LoweTo store the output speed in the termios structure pointed to by
1250bbf21555SRichard Lowe.Fa termios_p
1251bbf21555SRichard Lowesee the following code segment.
1252bbf21555SRichard Lowe.Bd -literal -offset 2n
1253bbf21555SRichard Lowespeed_t ospeed;
1254bbf21555SRichard Loweif (ospeed > CBAUD) {
1255bbf21555SRichard Lowe termios_p->c_cflag |= CBAUDEXT;
1256bbf21555SRichard Lowe ospeed -= (CBAUD + 1);
1257bbf21555SRichard Lowe} else {
1258bbf21555SRichard Lowe termios_p->c_cflag &= ~CBAUDEXT;
1259bbf21555SRichard Lowe}
1260bbf21555SRichard Lowetermios_p->c_cflag =
1261bbf21555SRichard Lowe  (termios_p->c_cflag & ~CBAUD) | (ospeed & CBAUD);
1262bbf21555SRichard Lowe.Ed
1263bbf21555SRichard Lowe.Pp
1264bbf21555SRichard LoweThe zero baud rate,
1265bbf21555SRichard Lowe.Dv B0 ,
1266bbf21555SRichard Loweis used to hang up the connection.
1267bbf21555SRichard LoweIf
1268bbf21555SRichard Lowe.Dv B0
1269bbf21555SRichard Loweis specified, the data-terminal-ready signal is not asserted.
1270bbf21555SRichard LoweNormally, this disconnects the line.
1271bbf21555SRichard Lowe.Pp
1272bbf21555SRichard LoweIf the
1273bbf21555SRichard Lowe.Dv CIBAUDEXT
1274bbf21555SRichard Loweor
1275bbf21555SRichard Lowe.Dv CIBAUD
1276bbf21555SRichard Lowebits are not zero, they specify the input baud rate, with the
1277bbf21555SRichard Lowe.Dv CBAUDEXT
1278bbf21555SRichard Loweand
1279bbf21555SRichard Lowe.Dv CBAUD
1280bbf21555SRichard Lowebits specifying the output baud rate; otherwise, the output and input baud
1281bbf21555SRichard Lowerates are both specified by the
1282bbf21555SRichard Lowe.Dv CBAUDEXT
1283bbf21555SRichard Loweand
1284bbf21555SRichard Lowe.Dv CBAUD
1285bbf21555SRichard Lowebits.
1286bbf21555SRichard LoweThe values for the
1287bbf21555SRichard Lowe.Dv CIBAUD
1288bbf21555SRichard Lowebits are the same as the values for the
1289bbf21555SRichard Lowe.Dv CBAUD
1290bbf21555SRichard Lowebits, shifted left
1291bbf21555SRichard Lowe.Dv IBSHIFT
1292bbf21555SRichard Lowebits.
1293bbf21555SRichard LoweFor any particular hardware, impossible speed changes are
1294bbf21555SRichard Loweignored.
1295bbf21555SRichard LoweTo retrieve the input speed in the
1296bbf21555SRichard Lowe.Vt termios
1297bbf21555SRichard Lowestructure pointed to
1298bbf21555SRichard Loweby
1299bbf21555SRichard Lowe.Fa termios_p
1300bbf21555SRichard Lowesee the following code segment.
1301bbf21555SRichard Lowe.Bd -literal -offset 2n
1302bbf21555SRichard Lowespeed_t ispeed;
1303bbf21555SRichard Loweif (termios_p->c_cflag & CIBAUDEXT) {
1304bbf21555SRichard Lowe ispeed = ((termios_p->c_cflag & CIBAUD) >> IBSHIFT)
1305bbf21555SRichard Lowe + (CIBAUD >> IBSHIFT) + 1;
1306bbf21555SRichard Lowe} else {
1307bbf21555SRichard Lowe ispeed = (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
1308bbf21555SRichard Lowe}
1309bbf21555SRichard Lowe.Ed
1310bbf21555SRichard Lowe.Pp
1311bbf21555SRichard LoweTo store the input speed in the
1312bbf21555SRichard Lowe.Vt termios
1313bbf21555SRichard Lowestructure pointed to by
1314bbf21555SRichard Lowe.Fa termios_p
1315bbf21555SRichard Lowesee the following code segment.
1316bbf21555SRichard Lowe.Bd -literal -offset 2n
1317bbf21555SRichard Lowespeed_t ispeed;
1318bbf21555SRichard Loweif (ispeed == 0) {
1319bbf21555SRichard Lowe ispeed = termios_p->c_cflag & CBAUD;
1320bbf21555SRichard Lowe if (termios_p->c_cflag & CBAUDEXT)
1321bbf21555SRichard Lowe     ispeed += (CBAUD + 1);
1322bbf21555SRichard Lowe}
1323bbf21555SRichard Loweif ((ispeed << IBSHIFT) > CIBAUD) {
1324bbf21555SRichard Lowe  termios_p->c_cflag |= CIBAUDEXT;
1325bbf21555SRichard Lowe  ispeed -= ((CIBAUD >> IBSHIFT) + 1);
1326bbf21555SRichard Lowe} else {
1327bbf21555SRichard Lowe  termios_p->c_cflag &= ~CIBAUDEXT;
1328bbf21555SRichard Lowe}
1329bbf21555SRichard Lowetermios_p->c_cflag =
1330bbf21555SRichard Lowe  (termios_p->c_cflag & ~CIBAUD) | ((ispeed << IBSHIFT) & CIBAUD);
1331bbf21555SRichard Lowe.Ed
1332bbf21555SRichard Lowe.Pp
1333bbf21555SRichard LoweThe
1334bbf21555SRichard Lowe.Dv CSIZE
1335bbf21555SRichard Lowebits specify the character size in bits for both transmission and reception.
1336bbf21555SRichard LoweThis size does not include the parity bit, if any.
1337bbf21555SRichard LoweIf
1338bbf21555SRichard Lowe.Dv CSTOPB
1339bbf21555SRichard Loweis set, two stop bits are used; otherwise, one stop bit is used.
1340bbf21555SRichard LoweFor example, at 110 baud, two stops bits are required.
1341bbf21555SRichard Lowe.Pp
1342bbf21555SRichard LoweIf
1343bbf21555SRichard Lowe.Dv PARENB
1344bbf21555SRichard Loweis set, parity generation and detection is enabled, and a
1345bbf21555SRichard Loweparity bit is added to each character.
1346bbf21555SRichard LoweIf parity is enabled, the
1347bbf21555SRichard Lowe.Dv PARODD
1348bbf21555SRichard Loweflag specifies odd parity if set; otherwise, even parity is used.
1349bbf21555SRichard Lowe.Pp
1350bbf21555SRichard LoweIf
1351bbf21555SRichard Lowe.Dv CREAD
1352bbf21555SRichard Loweis set, the receiver is enabled.
1353bbf21555SRichard LoweOtherwise, no characters are received.
1354bbf21555SRichard Lowe.Pp
1355bbf21555SRichard LoweIf
1356bbf21555SRichard Lowe.Dv HUPCL
1357bbf21555SRichard Loweis set, the line is disconnected when the last process with the
1358bbf21555SRichard Loweline open closes it or terminates.
1359bbf21555SRichard LoweThat is, the data-terminal-ready signal is not asserted.
1360bbf21555SRichard Lowe.Pp
1361bbf21555SRichard LoweIf
1362bbf21555SRichard Lowe.Dv CLOCAL
1363bbf21555SRichard Loweis set, the line is assumed to be a local, direct connection
1364bbf21555SRichard Lowewith no modem control; otherwise, modem control is assumed.
1365bbf21555SRichard Lowe.Pp
1366bbf21555SRichard LoweIf
1367bbf21555SRichard Lowe.Dv CRTSXOFF
1368bbf21555SRichard Loweis set, inbound hardware flow control is enabled.
1369bbf21555SRichard Lowe.Pp
1370bbf21555SRichard LoweIf
1371bbf21555SRichard Lowe.Dv CRTSCTS
1372bbf21555SRichard Loweis set, outbound hardware flow control is enabled.
1373bbf21555SRichard Lowe.Pp
1374bbf21555SRichard LoweThe four possible combinations for the state of
1375bbf21555SRichard Lowe.Dv CRTSCTS
1376bbf21555SRichard Loweand
1377bbf21555SRichard Lowe.Dv CRTSXOFF
1378bbf21555SRichard Lowebits and their interactions are described below.
1379bbf21555SRichard Lowe.Bl -tag -width "Case C:"
1380bbf21555SRichard Lowe.It Sy Case A :
1381bbf21555SRichard Lowe.Dv CRTSCTS
1382bbf21555SRichard Loweoff,
1383bbf21555SRichard Lowe.Dv CRTSXOFF
1384bbf21555SRichard Loweoff.
1385bbf21555SRichard LoweIn this case the hardware flow control is disabled.
1386bbf21555SRichard Lowe.It Sy Case B :
1387bbf21555SRichard Lowe.Dv CRTSCTS
1388bbf21555SRichard Loweon,
1389bbf21555SRichard Lowe.Dv CRTSXOFF
1390bbf21555SRichard Loweoff.
1391bbf21555SRichard LoweIn this case only outbound hardware flow control is enabled.
1392bbf21555SRichard LoweThe state of CTS signal is used to do outbound flow control.
1393bbf21555SRichard LoweIt is expected that output will be suspended if CTS is low and resumed
1394bbf21555SRichard Lowewhen CTS is high.
1395bbf21555SRichard Lowe.It Sy Case C :
1396bbf21555SRichard Lowe.Dv CRTSCTS
1397bbf21555SRichard Loweoff,
1398bbf21555SRichard Lowe.Dv CRTSXOFF
1399bbf21555SRichard Loweon.
1400bbf21555SRichard LoweIn this case only inbound hardware flow control is enabled.
1401bbf21555SRichard LoweThe state of RTS signal is used to do inbound flow control.
1402bbf21555SRichard LoweIt is expected that input will be suspended if RTS is low and resumed when RTS
1403bbf21555SRichard Loweis high.
1404bbf21555SRichard Lowe.It Sy Case D :
1405bbf21555SRichard Lowe.Dv CRTSCTS
1406bbf21555SRichard Loweon,
1407bbf21555SRichard Lowe.Dv CRTSXOFF
1408bbf21555SRichard Loweon.
1409bbf21555SRichard LoweIn this case both inbound and outbound hardware flow control are enabled.
1410bbf21555SRichard LoweUses the state of CTS signal to do outbound
1411bbf21555SRichard Loweflow control and RTS signal to do inbound flow control.
1412bbf21555SRichard Lowe.El
1413bbf21555SRichard Lowe.Ss "Local Modes"
1414bbf21555SRichard LoweThe
1415bbf21555SRichard Lowe.Fa c_lflag
1416bbf21555SRichard Lowefield of the argument structure is used by the line
1417bbf21555SRichard Lowediscipline to control terminal functions.
1418bbf21555SRichard LoweThe basic line discipline provides the following:
1419bbf21555SRichard Lowe.Pp
1420bbf21555SRichard Lowe.Bl -tag -offset 2n -width SIGTTOU -compact
1421bbf21555SRichard Lowe.It Dv ISIG
1422bbf21555SRichard LoweEnable signals.
1423bbf21555SRichard Lowe.It Dv ICANON
1424bbf21555SRichard LoweCanonical input (erase and kill processing).
1425bbf21555SRichard Lowe.It Dv XCASE
1426bbf21555SRichard LoweCanonical upper/lower presentation.
1427bbf21555SRichard Lowe.It Dv ECHO
1428bbf21555SRichard LoweEnable echo.
1429bbf21555SRichard Lowe.It Dv ECHOE
1430bbf21555SRichard LoweEcho erase character as
1431bbf21555SRichard Lowe.Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
1432bbf21555SRichard Lowe&.
1433bbf21555SRichard Lowe.It Dv ECHOK
1434bbf21555SRichard LoweEcho
1435bbf21555SRichard Lowe.Sy NL
1436bbf21555SRichard Loweafter kill character.
1437bbf21555SRichard Lowe.It Dv ECHONL
1438bbf21555SRichard LoweEcho
1439bbf21555SRichard Lowe.Sy NL .
1440bbf21555SRichard Lowe.It Dv NOFLSH
1441bbf21555SRichard LoweDisable flush after interrupt or quit.
1442bbf21555SRichard Lowe.It Dv TOSTOP
1443bbf21555SRichard LoweSend
1444bbf21555SRichard Lowe.It Dv SIGTTOU
1445bbf21555SRichard Lowefor background output.
1446bbf21555SRichard Lowe.It Dv ECHOCTL
1447bbf21555SRichard LoweEcho control characters as
1448bbf21555SRichard Lowe.Em char ,
1449bbf21555SRichard Lowedelete as ^?.
1450bbf21555SRichard Lowe.It Dv ECHOPRT
1451bbf21555SRichard LoweEcho erase character as character erased.
1452bbf21555SRichard Lowe.It Dv ECHOKE
1453bbf21555SRichard Lowe.Sy BS Ns - Ns Sy SP Ns - Ns Sy BS
1454bbf21555SRichard Loweerase entire line on line kill.
1455bbf21555SRichard Lowe.It Dv FLUSHO
1456bbf21555SRichard LoweOutput is being flushed.
1457bbf21555SRichard Lowe.It Dv PENDIN
1458bbf21555SRichard LoweRetype pending input at next read or input character.
1459bbf21555SRichard Lowe.It Dv IEXTEN
1460bbf21555SRichard LoweEnable extended (implementation-defined) functions.
1461bbf21555SRichard Lowe.El
1462bbf21555SRichard Lowe.Pp
1463bbf21555SRichard LoweIf
1464bbf21555SRichard Lowe.Dv ISIG
1465bbf21555SRichard Loweis set, each input character is checked against the special
1466bbf21555SRichard Lowecontrol characters
1467bbf21555SRichard Lowe.Sy INTR ,
1468bbf21555SRichard Lowe.Sy QUIT ,
1469bbf21555SRichard Lowe.Sy SWTCH ,
1470bbf21555SRichard Lowe.Sy SUSP ,
1471bbf21555SRichard Lowe.Sy STATUS ,
1472bbf21555SRichard Loweand
1473bbf21555SRichard Lowe.Sy DSUSP .
1474bbf21555SRichard LoweIf an input character matches one of these control characters, the function
1475bbf21555SRichard Loweassociated with that character is performed.
1476bbf21555SRichard Lowe.Po
1477bbf21555SRichard LoweNote: If
1478bbf21555SRichard Lowe.Sy SWTCH
1479bbf21555SRichard Loweis set and the character matches, the character is simply discarded.
1480bbf21555SRichard LoweNo other action is taken.
1481bbf21555SRichard Lowe.Pc
1482bbf21555SRichard LoweIf
1483bbf21555SRichard Lowe.Dv ISIG
1484bbf21555SRichard Loweis not set, no checking is done.
1485bbf21555SRichard LoweThus, these special
1486bbf21555SRichard Loweinput functions are possible only if
1487bbf21555SRichard Lowe.Dv ISIG
1488bbf21555SRichard Loweis set.
1489bbf21555SRichard Lowe.Pp
1490bbf21555SRichard LoweIf
1491bbf21555SRichard Lowe.Dv ICANON
1492bbf21555SRichard Loweis set, canonical processing is enabled.
1493bbf21555SRichard LoweThis enables the erase
1494bbf21555SRichard Loweand kill edit functions, and the assembly of input characters into lines
1495bbf21555SRichard Lowedelimited by
1496bbf21555SRichard Lowe.Sy NL-c ,
1497bbf21555SRichard Lowe.Sy EOF ,
1498bbf21555SRichard Lowe.Sy EOL ,
1499bbf21555SRichard Loweand
1500bbf21555SRichard Lowe.Sy EOL .
1501bbf21555SRichard LoweIf
1502bbf21555SRichard Lowe.Dv ICANON
1503bbf21555SRichard Loweis not set, read requests are satisfied directly from the input queue.
1504bbf21555SRichard LoweA read is not satisfied until at least
1505bbf21555SRichard Lowe.Sy MIN
1506bbf21555SRichard Lowecharacters have been received or the timeout value
1507bbf21555SRichard Lowe.Sy TIME
1508bbf21555SRichard Lowehas expired between characters.
1509bbf21555SRichard LoweThis allows fast bursts of input to be read efficiently while still allowing
1510bbf21555SRichard Lowesingle character input.
1511bbf21555SRichard LoweThe time value represents tenths of seconds.
1512bbf21555SRichard Lowe.Pp
1513bbf21555SRichard LoweIf
1514bbf21555SRichard Lowe.Dv XCASE
1515bbf21555SRichard Loweis set and
1516bbf21555SRichard Lowe.Dv ICANON
1517bbf21555SRichard Loweis set, an upper case letter is
1518bbf21555SRichard Loweaccepted on input if preceded by a backslash
1519bbf21555SRichard Lowe.Ql \e
1520bbf21555SRichard Lowecharacter, and is output preceded by a backslash
1521bbf21555SRichard Lowe.Ql \e
1522bbf21555SRichard Lowecharacter.
1523bbf21555SRichard LoweIn this mode, the
1524bbf21555SRichard Lowefollowing escape sequences are generated on output and accepted on input:
1525bbf21555SRichard Lowe.Bl -column "FOR:" "USE:" -offset 2n
1526bbf21555SRichard Lowe.It FOR: Ta USE:
1527bbf21555SRichard Lowe.It ` Ta \e'
1528bbf21555SRichard Lowe.It | Ta \e!
1529bbf21555SRichard Lowe.It \(ap Ta \e^
1530bbf21555SRichard Lowe.It { Ta \e(
1531bbf21555SRichard Lowe.It } Ta \e)
1532bbf21555SRichard Lowe.It \e Ta \e\e
1533bbf21555SRichard Lowe.El
1534bbf21555SRichard Lowe.Pp
1535bbf21555SRichard LoweFor example, input A as \ea, \en as \e\en, and \eN as \e\e\en.
1536bbf21555SRichard Lowe.Pp
1537bbf21555SRichard LoweIf
1538bbf21555SRichard Lowe.Dv ECHO
1539bbf21555SRichard Loweis set, characters are echoed as received.
1540bbf21555SRichard Lowe.Pp
1541bbf21555SRichard LoweWhen
1542bbf21555SRichard Lowe.Dv ICANON
1543bbf21555SRichard Loweis set, the following echo functions are possible.
1544bbf21555SRichard Lowe.Bl -bullet -offset indent
1545bbf21555SRichard Lowe.It
1546bbf21555SRichard LoweIf
1547bbf21555SRichard Lowe.Dv ECHO
1548bbf21555SRichard Loweand
1549bbf21555SRichard Lowe.Dv ECHOE
1550bbf21555SRichard Loweare set, and
1551bbf21555SRichard Lowe.Dv ECHOPRT
1552bbf21555SRichard Loweis not set, the
1553bbf21555SRichard Lowe.Sy ERASE ,
1554bbf21555SRichard Lowe.Sy ERASE2 ,
1555bbf21555SRichard Loweand
1556bbf21555SRichard Lowe.Sy WERASE
1557bbf21555SRichard Lowecharacters are echoed as one or
1558bbf21555SRichard Lowemore ASCII BS SP BS, which clears the last character(s) from a
1559bbf21555SRichard Lowe.Sy CRT
1560bbf21555SRichard Lowescreen.
1561bbf21555SRichard Lowe.It
1562bbf21555SRichard LoweIf
1563bbf21555SRichard Lowe.Dv ECHO ,
1564bbf21555SRichard Lowe.Dv ECHOPRT ,
1565bbf21555SRichard Loweand
1566bbf21555SRichard Lowe.Dv IEXTEN
1567bbf21555SRichard Loweare set, the first
1568bbf21555SRichard Lowe.Sy ERASE ,
1569bbf21555SRichard Lowe.Sy ERASE2 ,
1570bbf21555SRichard Loweand
1571bbf21555SRichard Lowe.Sy WERASE
1572bbf21555SRichard Lowecharacter in a sequence echoes as a backslash
1573bbf21555SRichard Lowe.Ql \e ,
1574bbf21555SRichard Lowefollowed by the characters being erased.
1575bbf21555SRichard LoweSubsequent
1576bbf21555SRichard Lowe.Sy ERASE
1577bbf21555SRichard Loweand
1578bbf21555SRichard Lowe.Sy WERASE
1579bbf21555SRichard Lowecharacters echo the characters being erased, in reverse order.
1580bbf21555SRichard LoweThe
1581bbf21555SRichard Lowenext non-erase character causes a
1582bbf21555SRichard Lowe.Ql /
1583bbf21555SRichard Lowe(slash) to be typed before it is echoed.
1584bbf21555SRichard Lowe.Dv ECHOPRT
1585bbf21555SRichard Loweshould be used for hard copy terminals.
1586bbf21555SRichard Lowe.It
1587bbf21555SRichard LoweIf
1588bbf21555SRichard Lowe.Dv ECHOKE
1589bbf21555SRichard Loweand
1590bbf21555SRichard Lowe.Dv IEXTEN
1591bbf21555SRichard Loweare set, the kill character is echoed by
1592bbf21555SRichard Loweerasing each character on the line from the screen (using the mechanism
1593bbf21555SRichard Loweselected by
1594bbf21555SRichard Lowe.Dv ECHOE
1595bbf21555SRichard Loweand
1596bbf21555SRichard Lowe.Dv ECHOPR ) .
1597bbf21555SRichard Lowe.It
1598bbf21555SRichard LoweIf
1599bbf21555SRichard Lowe.Dv ECHOK
1600bbf21555SRichard Loweis set, and
1601bbf21555SRichard Lowe.Dv ECHOKE
1602bbf21555SRichard Loweis not set, the
1603bbf21555SRichard Lowe.Sy NL
1604bbf21555SRichard Lowecharacter is
1605bbf21555SRichard Loweechoed after the kill character to emphasize that the line is deleted.
1606bbf21555SRichard LoweNote
1607bbf21555SRichard Lowethat a
1608bbf21555SRichard Lowe.Ql \e
1609bbf21555SRichard Lowe(escape) character or an
1610bbf21555SRichard Lowe.Sy LNEXT
1611bbf21555SRichard Lowecharacter preceding the erase
1612bbf21555SRichard Loweor kill character removes any special function.
1613bbf21555SRichard Lowe.It
1614bbf21555SRichard LoweIf
1615bbf21555SRichard Lowe.Dv ECHONL
1616bbf21555SRichard Loweis set, the
1617bbf21555SRichard Lowe.Sy NL
1618bbf21555SRichard Lowecharacter is echoed even if
1619bbf21555SRichard Lowe.Dv ECHO
1620bbf21555SRichard Loweis not set.
1621bbf21555SRichard LoweThis is useful for terminals set to local echo (so called
1622bbf21555SRichard Lowehalf-duplex).
1623bbf21555SRichard Lowe.El
1624bbf21555SRichard Lowe.Pp
1625bbf21555SRichard LoweIf
1626bbf21555SRichard Lowe.Dv ECHOCTL
1627bbf21555SRichard Loweand
1628bbf21555SRichard Lowe.Dv IEXTEN
1629bbf21555SRichard Loweare set, all control characters (characters
1630bbf21555SRichard Lowewith codes between 0 and 37 octal) other than
1631bbf21555SRichard Lowe.Sy ASCII TAB ,
1632bbf21555SRichard Lowe.Sy ASCII NL ,
1633bbf21555SRichard Lowethe
1634bbf21555SRichard Lowe.Sy START
1635bbf21555SRichard Lowecharacter, and the
1636bbf21555SRichard Lowe.Sy STOP
1637bbf21555SRichard Lowecharacter,
1638bbf21555SRichard Lowe.Sy ASCII CR ,
1639bbf21555SRichard Loweand
1640bbf21555SRichard Lowe.Sy ASCII BS
1641bbf21555SRichard Loweare echoed as
1642bbf21555SRichard Lowe.No ^ Ns Em X ,
1643bbf21555SRichard Lowewhere
1644bbf21555SRichard Lowe.Em X
1645bbf21555SRichard Loweis the character given by adding
1646bbf21555SRichard Lowe.Ql 100
1647bbf21555SRichard Loweoctal to the code of the control character (so
1648bbf21555SRichard Lowethat the character with octal code
1649bbf21555SRichard Lowe.Ql 1
1650bbf21555SRichard Loweis echoed as
1651bbf21555SRichard Lowe.No ^ Ns Sy A ) ,
1652bbf21555SRichard Loweand the
1653bbf21555SRichard Lowe.Sy ASCII DEL
1654bbf21555SRichard Lowecharacter,
1655bbf21555SRichard Lowewith code
1656bbf21555SRichard Lowe.Ql 177
1657bbf21555SRichard Loweoctal, is echoed as
1658bbf21555SRichard Lowe.No ^ Ns Sy \&? .
1659bbf21555SRichard Lowe.Pp
1660bbf21555SRichard LoweIf
1661bbf21555SRichard Lowe.Dv NOFLSH
1662bbf21555SRichard Loweis set, the normal flush of the input and output queues
1663bbf21555SRichard Loweassociated with the
1664bbf21555SRichard Lowe.Sy INTR ,
1665bbf21555SRichard Lowe.Sy QUIT ,
1666bbf21555SRichard Lowe.Sy STATUS ,
1667bbf21555SRichard Loweand
1668bbf21555SRichard Lowe.Sy SUSP
1669bbf21555SRichard Lowecharacters is not done.
1670bbf21555SRichard LoweThis bit should be set when restarting system calls
1671bbf21555SRichard Lowethat read from or write to a terminal
1672bbf21555SRichard Lowe.Po
1673bbf21555SRichard Lowesee
1674bbf21555SRichard Lowe.Xr sigaction 2
1675bbf21555SRichard Lowe.Pc .
1676bbf21555SRichard Lowe.Pp
1677bbf21555SRichard LoweIf
1678bbf21555SRichard Lowe.Dv TOSTOP
1679bbf21555SRichard Loweand
1680bbf21555SRichard Lowe.Dv IEXTEN
1681bbf21555SRichard Loweare set, the signal
1682bbf21555SRichard Lowe.Dv SIGTTOU
1683bbf21555SRichard Loweis sent to
1684bbf21555SRichard Lowea process that tries to write to its controlling terminal if it is not in the
1685bbf21555SRichard Loweforeground process group for that terminal.
1686bbf21555SRichard LoweThis signal normally stops the process.
1687bbf21555SRichard LoweOtherwise, the output generated by that process is output to the
1688bbf21555SRichard Lowecurrent output stream.
1689bbf21555SRichard LoweProcesses that are blocking or ignoring
1690bbf21555SRichard Lowe.Dv SIGTTOU
1691bbf21555SRichard Lowesignals are excepted and allowed to produce output, if any.
1692bbf21555SRichard Lowe.Pp
1693bbf21555SRichard LoweIf
1694bbf21555SRichard Lowe.Dv FLUSHO
1695bbf21555SRichard Loweand
1696bbf21555SRichard Lowe.Dv IEXTEN
1697bbf21555SRichard Loweare set, data written to the terminal is
1698bbf21555SRichard Lowediscarded.
1699bbf21555SRichard LoweThis bit is set when the
1700bbf21555SRichard Lowe.Sy FLUSH
1701bbf21555SRichard Lowecharacter is typed.
1702bbf21555SRichard LoweA program can cancel the effect of typing the
1703bbf21555SRichard Lowe.Sy FLUSH
1704bbf21555SRichard Lowecharacter by clearing
1705bbf21555SRichard Lowe.Dv FLUSHO .
1706bbf21555SRichard Lowe.Pp
1707bbf21555SRichard LoweIf
1708bbf21555SRichard Lowe.Dv PENDIN
1709bbf21555SRichard Loweand
1710bbf21555SRichard Lowe.Dv IEXTEN
1711bbf21555SRichard Loweare set, any input that has not yet been read
1712bbf21555SRichard Loweis reprinted when the next character arrives as input.
1713bbf21555SRichard Lowe.Dv PENDIN
1714bbf21555SRichard Loweis then
1715bbf21555SRichard Loweautomatically cleared.
1716bbf21555SRichard Lowe.Pp
1717bbf21555SRichard LoweIf
1718bbf21555SRichard Lowe.Dv IEXTEN
1719bbf21555SRichard Loweis set, the following implementation-defined functions are
1720bbf21555SRichard Loweenabled: special characters (
1721bbf21555SRichard Lowe.Sy WERASE ,
1722bbf21555SRichard Lowe.Sy REPRINT ,
1723bbf21555SRichard Lowe.Sy DISCARD ,
1724bbf21555SRichard Loweand
1725bbf21555SRichard Lowe.Sy LNEXT )
1726bbf21555SRichard Loweand local flags (
1727bbf21555SRichard Lowe.Dv TOSTOP ,
1728bbf21555SRichard Lowe.Dv ECHOCTL ,
1729bbf21555SRichard Lowe.Dv ECHOPRT ,
1730bbf21555SRichard Lowe.Dv ECHOKE ,
1731bbf21555SRichard Lowe.Dv FLUSHO ,
1732bbf21555SRichard Loweand
1733bbf21555SRichard Lowe.Dv PENDIN ) .
1734bbf21555SRichard Lowe.Ss "Minimum and Timeout"
1735bbf21555SRichard LoweThe
1736bbf21555SRichard Lowe.Sy MIN
1737bbf21555SRichard Loweand
1738bbf21555SRichard Lowe.Sy TIME
1739bbf21555SRichard Lowevalues were described previously, in the
1740bbf21555SRichard Lowesubsection,
1741bbf21555SRichard Lowe.Sy Non-canonical Mode Input Processing .
1742bbf21555SRichard LoweThe initial value of
1743bbf21555SRichard Lowe.Sy MIN
1744bbf21555SRichard Loweis 1, and the initial value of
1745bbf21555SRichard Lowe.Sy TIME
1746bbf21555SRichard Loweis 0.
1747bbf21555SRichard Lowe.Ss "Terminal Size"
1748bbf21555SRichard LoweThe number of lines and columns on the terminal's display is specified in the
1749bbf21555SRichard Lowe.Vt winsize
1750bbf21555SRichard Lowestructure defined by
1751bbf21555SRichard Lowe.In sys/termios.h
1752bbf21555SRichard Loweand includes the following members:
1753bbf21555SRichard Lowe.Bd -literal -offset 2n
1754bbf21555SRichard Loweunsigned	short ws_row;  /* rows, in characters */
1755bbf21555SRichard Loweunsigned short	ws_col;        /* columns, in characters */
1756bbf21555SRichard Loweunsigned short	ws_xpixel;     /* horizontal size, in pixels */
1757bbf21555SRichard Loweunsigned short	ws_ypixel;     /* vertical size, in pixels */
1758bbf21555SRichard Lowe.Ed
1759bbf21555SRichard Lowe.Ss "Termio Structure"
1760bbf21555SRichard LoweThe SunOS/SVR4
1761bbf21555SRichard Lowe.Vt termio
1762bbf21555SRichard Lowestructure is used by some
1763bbf21555SRichard Lowe.Fn ioctl Ns s ;
1764bbf21555SRichard Loweit is defined by
1765bbf21555SRichard Lowe.In sys/termio.h
1766bbf21555SRichard Loweand includes the following members:
1767bbf21555SRichard Lowe.Bd -literal -offset 2n
1768bbf21555SRichard Loweunsigned	short	c_iflag;    /* input modes */
1769bbf21555SRichard Loweunsigned	short	c_oflag;    /* output modes */
1770bbf21555SRichard Loweunsigned	short	c_cflag;    /* control modes */
1771bbf21555SRichard Loweunsigned	short	c_lflag;    /* local modes */
1772bbf21555SRichard Lowechar			c_line;     /* line discipline */
1773bbf21555SRichard Loweunsigned	char	c_cc[NCC];  /* control chars */
1774bbf21555SRichard Lowe.Ed
1775bbf21555SRichard Lowe.Pp
1776bbf21555SRichard LoweThe special control characters are defined by the array
1777bbf21555SRichard Lowe.Fa c_cc .
1778bbf21555SRichard LoweThe symbolic name
1779bbf21555SRichard Lowe.Dv NCC
1780bbf21555SRichard Loweis the size of the Control-character array and is also
1781bbf21555SRichard Lowedefined by
1782bbf21555SRichard Lowe.In termio.h .
1783bbf21555SRichard LoweThe relative positions, subscript names, and typical
1784bbf21555SRichard Lowedefault values for each function are as follows:
1785bbf21555SRichard Lowe.Bl -column "Relative Positions" "Subscript Names" "Typical Default Values"
1786bbf21555SRichard Lowe.It Relative Positions Ta Subscript Names Ta Typical Default Values
1787bbf21555SRichard Lowe.It 0 Ta VINTR Ta EXT
1788bbf21555SRichard Lowe.It 1 Ta VQUIT Ta FS
1789bbf21555SRichard Lowe.It 2 Ta VERASE Ta DEL
1790bbf21555SRichard Lowe.It 3 Ta VKILL Ta NAK
1791bbf21555SRichard Lowe.It 4 Ta VEOF Ta EOT
1792bbf21555SRichard Lowe.It 5 Ta VEOL Ta NUL
1793bbf21555SRichard Lowe.It 6 Ta VEOL2 Ta NUL
1794bbf21555SRichard Lowe.It 7 Ta Reserved Ta
1795bbf21555SRichard Lowe.El
1796bbf21555SRichard Lowe.Pp
1797bbf21555SRichard LoweThe
1798bbf21555SRichard Lowe.Sy MIN
1799bbf21555SRichard Lowevalues is stored in the
1800bbf21555SRichard Lowe.Dv VMIN
1801bbf21555SRichard Loweelement of the
1802bbf21555SRichard Lowe.Fa c_cc
1803bbf21555SRichard Lowearray; the
1804bbf21555SRichard Lowe.Sy TIME
1805bbf21555SRichard Lowevalue is stored in the
1806bbf21555SRichard Lowe.Dv VTIME
1807bbf21555SRichard Loweelement of the
1808bbf21555SRichard Lowe.Fa c_cc
1809bbf21555SRichard Lowearray.
1810bbf21555SRichard LoweThe
1811bbf21555SRichard Lowe.Dv VMIN
1812bbf21555SRichard Loweelement is the same element as the
1813bbf21555SRichard Lowe.Dv VEOF
1814bbf21555SRichard Loweelement; the
1815bbf21555SRichard Lowe.Dv VTIME
1816bbf21555SRichard Loweelement is the same element as the
1817bbf21555SRichard Lowe.Dv VEOL
1818bbf21555SRichard Loweelement.
1819bbf21555SRichard Lowe.Pp
1820bbf21555SRichard LoweThe calls that use the
1821bbf21555SRichard Lowe.Va termio
1822bbf21555SRichard Lowestructure only affect the flags and control
1823bbf21555SRichard Lowecharacters that can be stored in the
1824bbf21555SRichard Lowe.Vt termio
1825bbf21555SRichard Lowestructure; all other flags and control characters are unaffected.
1826bbf21555SRichard Lowe.Ss "Modem Lines"
1827bbf21555SRichard LoweOn special files representing serial ports, modem control lines can be read.
1828bbf21555SRichard LoweControl lines (if the underlying hardware supports it) may also be changed.
1829bbf21555SRichard LoweStatus lines are read-only.
1830bbf21555SRichard LoweThe following modem control and status lines may be
1831bbf21555SRichard Lowesupported by a device; they are defined by
1832bbf21555SRichard Lowe.In sys/termios.h :
1833bbf21555SRichard Lowe.Pp
1834bbf21555SRichard Lowe.Bl -tag -width "TIOCM_DTR" -compact -offset 2n
1835bbf21555SRichard Lowe.It Dv TIOCM_LE
1836bbf21555SRichard Loweline enable
1837bbf21555SRichard Lowe.It Dv TIOCM_DTR
1838bbf21555SRichard Lowedata terminal ready
1839bbf21555SRichard Lowe.It Dv TIOCM_RTS
1840bbf21555SRichard Lowerequest to send
1841bbf21555SRichard Lowe.It Dv TIOCM_ST
1842bbf21555SRichard Lowesecondary transmit
1843bbf21555SRichard Lowe.It Dv TIOCM_SR
1844bbf21555SRichard Lowesecondary receive
1845bbf21555SRichard Lowe.It Dv TIOCM_CTS
1846bbf21555SRichard Loweclear to send
1847bbf21555SRichard Lowe.It Dv TIOCM_CAR
1848bbf21555SRichard Lowecarrier detect
1849bbf21555SRichard Lowe.It Dv TIOCM_RNG
1850bbf21555SRichard Lowering
1851bbf21555SRichard Lowe.It Dv TIOCM_DSR
1852bbf21555SRichard Lowedata set ready
1853bbf21555SRichard Lowe.El
1854bbf21555SRichard Lowe.Pp
1855bbf21555SRichard Lowe.Dv TIOCM_CD
1856bbf21555SRichard Loweis a synonym for
1857bbf21555SRichard Lowe.Dv TIOCM_CAR ,
1858bbf21555SRichard Loweand
1859bbf21555SRichard Lowe.Dv TIOCM_RI
1860bbf21555SRichard Loweis a synonym for
1861bbf21555SRichard Lowe.Dv TIOCM_RNG .
1862bbf21555SRichard LoweNot all of these are necessarily supported by any
1863bbf21555SRichard Loweparticular device; check the manual page for the device in question.
1864bbf21555SRichard Lowe.Pp
1865bbf21555SRichard LoweThe software carrier mode can be enabled or disabled using the
1866bbf21555SRichard Lowe.Dv TIOCSSOFTCAR
1867bbf21555SRichard Lowe.Fn ioctl .
1868bbf21555SRichard LoweIf the software carrier flag for a line is off,
1869bbf21555SRichard Lowethe line pays attention to the hardware carrier detect (DCD) signal.
1870bbf21555SRichard LoweThe
1871bbf21555SRichard Lowe.Sy tty
1872bbf21555SRichard Lowedevice associated with the line cannot be opened until
1873bbf21555SRichard Lowe.Sy DCD
1874bbf21555SRichard Loweis asserted.
1875bbf21555SRichard LoweIf the software carrier flag is on, the line behaves as if
1876bbf21555SRichard Lowe.Sy DCD
1877bbf21555SRichard Loweis always asserted.
1878bbf21555SRichard Lowe.Pp
1879bbf21555SRichard LoweThe software carrier flag is usually turned on for locally connected terminals
1880bbf21555SRichard Loweor other devices, and is off for lines with modems.
1881bbf21555SRichard Lowe.Pp
1882bbf21555SRichard LoweTo be able to issue the
1883bbf21555SRichard Lowe.Dv TIOCGSOFTCAR
1884bbf21555SRichard Loweand
1885bbf21555SRichard Lowe.Dv TIOCSSOFTCAR
1886bbf21555SRichard Lowe.Fn ioctl
1887bbf21555SRichard Lowecalls, the
1888bbf21555SRichard Lowe.Sy tty
1889bbf21555SRichard Loweline should be opened with
1890bbf21555SRichard Lowe.Dv O_NDELAY
1891bbf21555SRichard Loweso that the
1892bbf21555SRichard Lowe.Xr open 2
1893bbf21555SRichard Lowewill not wait for the carrier.
1894bbf21555SRichard Lowe.Ss "Default Values"
1895bbf21555SRichard LoweThe initial
1896bbf21555SRichard Lowe.Vt termios
1897bbf21555SRichard Lowevalues upon driver open is configurable.
1898bbf21555SRichard LoweThis is accomplished by setting the "ttymodes" property in the file
1899bbf21555SRichard Lowe.Pa /kernel/drv/options.conf .
1900bbf21555SRichard LoweSince this property is assigned during system
1901bbf21555SRichard Loweinitialization, any change to the "ttymodes" property will not take effect
1902bbf21555SRichard Loweuntil the next reboot.
1903bbf21555SRichard LoweThe string value assigned to this property should be in
1904bbf21555SRichard Lowethe same format as the output of the
1905bbf21555SRichard Lowe.Xr stty 1
1906bbf21555SRichard Lowecommand with the -g option.
1907bbf21555SRichard Lowe.Pp
1908bbf21555SRichard LoweIf this property is undefined, the following
1909bbf21555SRichard Lowe.Vt termios
1910bbf21555SRichard Lowemodes are in effect.
1911bbf21555SRichard LoweThe initial input control value is
1912bbf21555SRichard Lowe.Dv BRKINT ,
1913bbf21555SRichard Lowe.Dv ICRNL ,
1914bbf21555SRichard Lowe.Dv IXON ,
1915bbf21555SRichard Lowe.Dv IMAXBEL .
1916bbf21555SRichard LoweThe initial output control value is
1917bbf21555SRichard Lowe.Dv OPOST ,
1918bbf21555SRichard Lowe.Dv ONLCR ,
1919bbf21555SRichard Lowe.Dv TAB3 .
1920bbf21555SRichard LoweThe initial hardware control value is
1921bbf21555SRichard Lowe.Dv B9600 ,
1922bbf21555SRichard Lowe.Dv CS8 ,
1923bbf21555SRichard Lowe.Dv CREAD .
1924bbf21555SRichard LoweThe initial line-discipline control value is
1925bbf21555SRichard Lowe.Dv ISIG ,
1926bbf21555SRichard Lowe.Dv ICANON ,
1927bbf21555SRichard Lowe.Dv IEXTEN ,
1928bbf21555SRichard Lowe.Dv ECHO ,
1929bbf21555SRichard Lowe.Dv ECHOK ,
1930bbf21555SRichard Lowe.Dv ECHOE ,
1931bbf21555SRichard Lowe.Dv ECHOKE ,
1932bbf21555SRichard Lowe.Dv ECHOCTL .
1933bbf21555SRichard Lowe.Sh IOCTLS
1934bbf21555SRichard LoweThe
1935bbf21555SRichard Lowe.Fn ioctl Ns s
1936bbf21555SRichard Lowesupported by devices and
1937bbf21555SRichard Lowe.Sy STREAMS
1938bbf21555SRichard Lowemodules providing the
1939bbf21555SRichard Lowe.Xr termios 3C
1940bbf21555SRichard Loweinterface are listed below.
1941bbf21555SRichard LoweSome calls may not be supported by all devices or modules.
1942bbf21555SRichard LoweThe functionality provided by these calls is also
1943bbf21555SRichard Loweavailable through the preferred function call interface specified on
1944bbf21555SRichard Lowe.Nm termios .
1945bbf21555SRichard Lowe.Bl -tag -width TIOCSSOFTCAR
1946bbf21555SRichard Lowe.It Dv TCGETS
1947bbf21555SRichard LoweThe argument is a pointer to a
1948bbf21555SRichard Lowe.Vt termios
1949bbf21555SRichard Lowestructure.
1950bbf21555SRichard LoweThe current terminal parameters are fetched and stored into that structure.
1951bbf21555SRichard Lowe.It Dv TCSETS
1952bbf21555SRichard LoweThe argument is a pointer to a
1953bbf21555SRichard Lowe.Vt termios
1954bbf21555SRichard Lowestructure.
1955bbf21555SRichard LoweThe current terminal parameters are set from the values stored in that structure.
1956bbf21555SRichard LoweThe change is immediate.
1957bbf21555SRichard Lowe.It Dv TCSETSW
1958bbf21555SRichard LoweThe argument is a pointer to a
1959bbf21555SRichard Lowe.Vt termios
1960bbf21555SRichard Lowestructure.
1961bbf21555SRichard LoweThe current terminal parameters are set from the values stored in that structure.
1962bbf21555SRichard LoweThe change occurs after all characters queued for output have been transmitted.
1963bbf21555SRichard LoweThis form should be used when changing parameters that affect output.
1964bbf21555SRichard Lowe.It Dv TCSETSF
1965bbf21555SRichard LoweThe argument is a pointer to a
1966bbf21555SRichard Lowe.Vt termios
1967bbf21555SRichard Lowestructure.
1968bbf21555SRichard LoweThe current terminal parameters are set from the values stored in that structure.
1969bbf21555SRichard LoweThe change occurs after all characters queued for output have been transmitted;
1970bbf21555SRichard Loweall characters queued for input are discarded and then the change occurs.
1971bbf21555SRichard Lowe.It Dv TCGETA
1972bbf21555SRichard LoweThe argument is a pointer to a
1973bbf21555SRichard Lowe.Vt termio
1974bbf21555SRichard Lowestructure.
1975bbf21555SRichard LoweThe current terminal parameters are fetched, and those parameters that can be
1976bbf21555SRichard Lowestored in a
1977bbf21555SRichard Lowe.Vt termio
1978bbf21555SRichard Lowestructure are stored into that structure.
1979bbf21555SRichard Lowe.It Dv TCSETA
1980bbf21555SRichard LoweThe argument is a pointer to a
1981bbf21555SRichard Lowe.Vt termio
1982bbf21555SRichard Lowestructure.
1983bbf21555SRichard LoweThose terminal parameters that can be stored in a
1984bbf21555SRichard Lowe.Vt termio
1985bbf21555SRichard Lowestructure are set from the values stored in that structure.
1986bbf21555SRichard LoweThe change is immediate.
1987bbf21555SRichard Lowe.It Dv TCSETAW
1988bbf21555SRichard LoweThe argument is a pointer to a
1989bbf21555SRichard Lowe.Vt termio
1990bbf21555SRichard Lowestructure.
1991bbf21555SRichard LoweThose terminal parameters that can be stored in a
1992bbf21555SRichard Lowe.Vt termio
1993bbf21555SRichard Lowestructure are set from
1994bbf21555SRichard Lowethe values stored in that structure.
1995bbf21555SRichard LoweThe change occurs after all characters queued for output have been transmitted.
1996bbf21555SRichard LoweThis form should be used when changing parameters that affect output.
1997bbf21555SRichard Lowe.It Dv TCSETAF
1998bbf21555SRichard LoweThe argument is a pointer to a
1999bbf21555SRichard Lowe.Vt termio
2000bbf21555SRichard Lowestructure.
2001bbf21555SRichard LoweThose terminal parameters that can be stored in a
2002bbf21555SRichard Lowe.Vt termio
2003bbf21555SRichard Lowestructure are set from the values stored in that structure.
2004bbf21555SRichard LoweThe change occurs after all characters queued
2005bbf21555SRichard Lowefor output have been transmitted; all characters queued for input are discarded
2006bbf21555SRichard Loweand then the change occurs.
2007bbf21555SRichard Lowe.It Dv TCSBRK
2008bbf21555SRichard LoweThe argument is an
2009bbf21555SRichard Lowe.Vt int
2010bbf21555SRichard Lowevalue.
2011bbf21555SRichard LoweWait for the output to drain.
2012bbf21555SRichard LoweIf the argument is
2013bbf21555SRichard Lowe.Sy 0 ,
2014bbf21555SRichard Lowethen send a break (zero valued bits for 0\&.25 seconds).
2015bbf21555SRichard Lowe.It Dv TCXONC
2016bbf21555SRichard LoweStart/stop control.
2017bbf21555SRichard LoweThe argument is an
2018bbf21555SRichard Lowe.Vt int
2019bbf21555SRichard Lowevalue.
2020bbf21555SRichard LoweIf the argument is
2021bbf21555SRichard Lowe.Sy 0 ,
2022bbf21555SRichard Lowesuspend output; if
2023bbf21555SRichard Lowe.Sy 1 ,
2024bbf21555SRichard Lowerestart suspended output; if
2025bbf21555SRichard Lowe.Sy 2 ,
2026bbf21555SRichard Lowesuspend input; if
2027bbf21555SRichard Lowe.Sy 3 ,
2028bbf21555SRichard Lowerestart suspended input.
2029bbf21555SRichard Lowe.It Dv TCFLSH
2030bbf21555SRichard LoweThe argument is an
2031bbf21555SRichard Lowe.Vt int
2032bbf21555SRichard Lowevalue.
2033bbf21555SRichard LoweIf the argument is
2034bbf21555SRichard Lowe.Sy 0 ,
2035bbf21555SRichard Loweflush the input queue; if
2036bbf21555SRichard Lowe.Sy 1 ,
2037bbf21555SRichard Loweflush the output queue; if
2038bbf21555SRichard Lowe.Sy 2 ,
2039bbf21555SRichard Loweflush both the input and output queues.
2040bbf21555SRichard Lowe.It Dv TIOCGPGRP
2041bbf21555SRichard LoweThe argument is a pointer to a
2042bbf21555SRichard Lowe.Vt pid_t .
2043bbf21555SRichard LoweSet the value of that
2044bbf21555SRichard Lowe.Vt pid_t
2045bbf21555SRichard Loweto the process group
2046bbf21555SRichard Lowe.Sy ID
2047bbf21555SRichard Loweof the foreground process group associated with the terminal.
2048bbf21555SRichard LoweSee
2049bbf21555SRichard Lowe.Xr termios 3C
2050bbf21555SRichard Lowefor a description of
2051bbf21555SRichard Lowe.Dv TCGETPGRP .
2052bbf21555SRichard Lowe.It Dv TIOCSPGRP
2053bbf21555SRichard LoweThe argument is a pointer to a
2054bbf21555SRichard Lowe.Vt pid_t .
2055bbf21555SRichard LoweAssociate the process group whose
2056bbf21555SRichard Loweprocess group
2057bbf21555SRichard Lowe.Sy ID
2058bbf21555SRichard Loweis specified by the value of that
2059bbf21555SRichard Lowe.Vt pid_t
2060bbf21555SRichard Lowewith the terminal.
2061bbf21555SRichard LoweThe new process group value must be in the range of valid process
2062bbf21555SRichard Lowegroup
2063bbf21555SRichard Lowe.Sy ID
2064bbf21555SRichard Lowevalues.
2065bbf21555SRichard LoweOtherwise, the error
2066bbf21555SRichard Lowe.Er EPERM
2067bbf21555SRichard Loweis returned.
2068bbf21555SRichard Lowe.It Dv TIOCGSID
2069bbf21555SRichard LoweThe argument is a pointer to a
2070bbf21555SRichard Lowe.Vt pid_t .
2071bbf21555SRichard LoweThe session ID of the terminal is fetched and stored in the
2072bbf21555SRichard Lowe.Vt pid_t .
2073bbf21555SRichard Lowe.It Dv TIOCGWINSZ
2074bbf21555SRichard LoweThe argument is a pointer to a
2075bbf21555SRichard Lowe.Vt winsize
2076bbf21555SRichard Lowestructure.
2077bbf21555SRichard LoweThe terminal driver's
2078bbf21555SRichard Lowenotion of the terminal size is stored into that structure.
2079bbf21555SRichard Lowe.It Dv TIOCSWINSZ
2080bbf21555SRichard LoweThe argument is a pointer to a
2081bbf21555SRichard Lowe.Vt winsize
2082bbf21555SRichard Lowestructure.
2083bbf21555SRichard LoweThe terminal driver's
2084bbf21555SRichard Lowenotion of the terminal size is set from the values specified in that structure.
2085bbf21555SRichard LoweIf the new sizes are different from the old sizes, a
2086bbf21555SRichard Lowe.Dv SIGWINCH
2087bbf21555SRichard Lowesignal is set to the process group of the terminal.
2088bbf21555SRichard Lowe.It Dv TIOCMBIS
2089bbf21555SRichard LoweThe argument is a pointer to an
2090bbf21555SRichard Lowe.Vt int
2091bbf21555SRichard Lowewhose value is a mask containing modem control lines to be turned on.
2092bbf21555SRichard LoweThe control lines whose bits are set in
2093bbf21555SRichard Lowethe argument are turned on; no other control lines are affected.
2094bbf21555SRichard Lowe.It Dv TIOCMBIC
2095bbf21555SRichard LoweThe argument is a pointer to an
2096bbf21555SRichard Lowe.Vt int
2097bbf21555SRichard Lowewhose value is a mask containing modem control lines to be turned off.
2098bbf21555SRichard LoweThe control lines whose bits are set in
2099bbf21555SRichard Lowethe argument are turned off; no other control lines are affected.
2100bbf21555SRichard Lowe.It Dv TIOCMGET
2101bbf21555SRichard LoweThe argument is a pointer to an
2102bbf21555SRichard Lowe.Vt int .
2103bbf21555SRichard LoweThe current state of the modem
2104bbf21555SRichard Lowestatus lines is fetched and stored in the
2105bbf21555SRichard Lowe.Vt int
2106bbf21555SRichard Lowepointed to by the argument.
2107bbf21555SRichard Lowe.It Dv TIOCMSET
2108bbf21555SRichard LoweThe argument is a pointer to an
2109bbf21555SRichard Lowe.Vt int
2110bbf21555SRichard Lowecontaining a new set of modem control lines.
2111bbf21555SRichard LoweThe modem control lines are turned on or off, depending on
2112bbf21555SRichard Lowewhether the bit for that mode is set or clear.
2113bbf21555SRichard Lowe.It Dv TIOCSPPS
2114bbf21555SRichard LoweThe argument is a pointer to an
2115bbf21555SRichard Lowe.Vt int
2116bbf21555SRichard Lowethat determines whether pulse-per-second event handling is to be enabled
2117bbf21555SRichard Lowe(non-zero) or disabled (zero).
2118bbf21555SRichard LoweIf a one-pulse-per-second reference clock is attached to the serial line's data
2119bbf21555SRichard Lowecarrier detect input, the local system clock will be calibrated to it.
2120bbf21555SRichard LoweA clock with a high error, that is, a deviation of more than 25 microseconds
2121bbf21555SRichard Loweper tick, is ignored.
2122bbf21555SRichard Lowe.It Dv TIOCGPPS
2123bbf21555SRichard LoweThe argument is a pointer to an
2124bbf21555SRichard Lowe.Vt int ,
2125bbf21555SRichard Lowein which the state of the even handling is returned.
2126bbf21555SRichard LoweThe
2127bbf21555SRichard Lowe.Vt int
2128bbf21555SRichard Loweis set to a non-zero value if pulse-per-second (PPS) handling has been enabled.
2129bbf21555SRichard LoweOtherwise, it is set to zero.
2130bbf21555SRichard Lowe.It Dv TIOCGSOFTCAR
2131bbf21555SRichard LoweThe argument is a pointer to an
2132bbf21555SRichard Lowe.Vt int
2133bbf21555SRichard Lowewhose value is
2134bbf21555SRichard Lowe.Sy 1
2135bbf21555SRichard Loweor
2136bbf21555SRichard Lowe.Sy 0 ,
2137bbf21555SRichard Lowedepending on whether the software carrier detect is turned on or off.
2138bbf21555SRichard Lowe.It Dv TIOCSSOFTCAR
2139bbf21555SRichard LoweThe argument is a pointer to an
2140bbf21555SRichard Lowe.Vt int
2141bbf21555SRichard Lowewhose value is
2142bbf21555SRichard Lowe.Sy 1
2143bbf21555SRichard Loweor
2144bbf21555SRichard Lowe.Sy 0 .
2145bbf21555SRichard LoweThe value of the integer should be
2146bbf21555SRichard Lowe.Sy 0
2147bbf21555SRichard Loweto turn off software carrier, or
2148bbf21555SRichard Lowe.Sy 1
2149bbf21555SRichard Loweto turn it on.
2150bbf21555SRichard Lowe.It Dv TIOCGPPSEV
2151bbf21555SRichard LoweThe argument is a pointer to a
2152bbf21555SRichard Lowe.Vt "struct ppsclockev" .
2153bbf21555SRichard LoweThis structure contains the following members:
2154bbf21555SRichard Lowe.Bd -literal -offset 2n
2155bbf21555SRichard Lowestruct timeval tv;
2156bbf21555SRichard Loweuint32_t serial;
2157bbf21555SRichard Lowe.Ed
2158bbf21555SRichard Lowe.Pp
2159bbf21555SRichard Lowe.Fa tv
2160bbf21555SRichard Loweis the system clock timestamp when the event (pulse on the
2161bbf21555SRichard Lowe.Sy DCD
2162bbf21555SRichard Lowepin) occurred.
2163bbf21555SRichard Lowe.Fa serial
2164bbf21555SRichard Loweis the ordinal of the event, which each consecutive event
2165bbf21555SRichard Lowebeing assigned the next ordinal.
2166bbf21555SRichard LoweThe first event registered gets a
2167bbf21555SRichard Lowe.Fa serial
2168bbf21555SRichard Lowevalue of
2169bbf21555SRichard Lowe.Sy 1 .
2170bbf21555SRichard LoweThe
2171bbf21555SRichard Lowe.Dv TIOCGPPSEV
2172bbf21555SRichard Lowereturns the last event registered; multiple calls will persistently return the
2173bbf21555SRichard Lowesame event until a new one is registered.
2174bbf21555SRichard LoweIn addition to time stamping and saving the event, if it is of
2175bbf21555SRichard Loweone-second period and of consistently high accuracy, the local system clock
2176bbf21555SRichard Lowewill automatically calibrate to it.
2177bbf21555SRichard Lowe.El
2178bbf21555SRichard Lowe.Sh FILES
2179bbf21555SRichard LoweFiles in or under
2180bbf21555SRichard Lowe.Pa /dev
2181bbf21555SRichard Lowe.Sh SEE ALSO
2182bbf21555SRichard Lowe.Xr stty 1 ,
2183bbf21555SRichard Lowe.Xr fork 2 ,
2184bbf21555SRichard Lowe.Xr getpgid 2 ,
2185bbf21555SRichard Lowe.Xr getsid 2 ,
2186bbf21555SRichard Lowe.Xr ioctl 2 ,
2187bbf21555SRichard Lowe.Xr setsid 2 ,
2188bbf21555SRichard Lowe.Xr sigaction 2 ,
2189bbf21555SRichard Lowe.Xr signal 3C ,
2190bbf21555SRichard Lowe.Xr tcsetpgrp 3C ,
2191bbf21555SRichard Lowe.Xr termios 3C ,
2192bbf21555SRichard Lowe.Xr signal.h 3HEAD ,
2193bbf21555SRichard Lowe.Xr streamio 4I
2194