xref: /csrg-svn/share/man/man4/termios.4 (revision 55008)
1*55008Scael.\" Copyright (c) 1991, 1992 The Regents of the University of California.
251195Sbostic.\" All rights reserved.
351195Sbostic.\"
451195Sbostic.\" %sccs.include.redist.roff%
551195Sbostic.\"
6*55008Scael.\"	@(#)termios.4	5.2 (Berkeley) 07/12/92
751195Sbostic.\"
8*55008Scael.Dd
9*55008Scael.Dt TERMIOS 4
10*55008Scael.Os BSD 4
11*55008Scael.Sh NAME
12*55008Scael.Nm termios
13*55008Scael.Nd general terminal interface
14*55008Scael.Sh SYNOPSIS
15*55008Scael.Fd #include <termios.h>
16*55008Scael.Sh DESCRIPTION
1751194SmarcThis describes a general terminal line discipline that is
1851194Smarcsupported on tty asynchronous communication ports.
19*55008Scael.Ss Opening a Terminal Device File
2051194SmarcWhen a terminal file is opened, it normally causes the process to wait
2151194Smarcuntil a connection is established.  For most hardware, the presence
22*55008Scaelof a connection is indicated by the assertion of the hardware
23*55008Scael.Dv CARRIER line.
2451194SmarcIf the termios structure associated with the terminal file has the
25*55008Scael.Dv CLOCAL
26*55008Scaelflag set in the cflag, or if the
27*55008Scael.Dv O_NONBLOCK
28*55008Scaelflag is set
29*55008Scaelin the
30*55008Scael.Xr open 2
31*55008Scaelcall, then the open will succeed even without
3251194Smarca connection being present.
3351194SmarcIn practice, applications
3451194Smarcseldom open these files; they are opened by special programs, such
35*55008Scaelas
36*55008Scael.Xr getty 2
37*55008Scaelor
38*55008Scael.Xr rlogind 2 ,
39*55008Scaeland become
4051194Smarcan application's standard input, output, and error files.
41*55008Scael.Ss Job Control in a Nutshell
4251194SmarcEvery process is associated with a particular process group and session.
43*55008ScaelThe grouping is hierarchical: every member of a particular process group is a
4451194Smarcmember of the same session.  This structuring is used in managing groups
45*55008Scaelof related processes for purposes of
46*55008Scael.\" .Gw "job control" ;
47*55008Scael.Em "job control" ;
48*55008Scaelthat is, the
49*55008Scaelability from the keyboard (or from program control) to simultaneously
5051194Smarcstop or restart
5151194Smarca complex command (a command composed of one or more related
5251194Smarcprocesses).  The grouping into process groups allows delivering
5351194Smarcof signals that stop or start the group as a whole, along with
5451194Smarcarbitrating which process group has access to the single controlling
55*55008Scaelterminal.  The grouping at a higher layer into sessions is to restrict
5651194Smarcthe job control related signals and system calls to within processes
5751194Smarcresulting from a particular instance of a "login".  Typically, a session
5851194Smarcis created when a user logs in, and the login terminal is setup
5951194Smarcto be the controlling terminal; all processes spawned from that
6051194Smarclogin shell are in the same session, and inherit the controlling
61*55008Scaelterminal.
6251194SmarcA job control shell
6351194Smarcoperating interactively (that is, reading commands from a terminal)
6451194Smarcnormally groups related processes together by placing them into the
6551194Smarcsame process group.  A set of processes in the same process group
66*55008Scaelis collectively refered to as a "job". When the foreground process
6751194Smarcgroup of the terminal is the same as the process group of a particular
6851194Smarcjob, that job is said to be in the "foreground".  When the process
6951194Smarcgroup of the terminal is different than the process group of
70*55008Scaela job (but is still the controlling terminal), that job is said
7151194Smarcto be in the "background".  Normally the
7251194Smarcshell reads a command and starts the job that implements that
7351194Smarccommand.  If the command is to be started in the foreground (typical), it
7451194Smarcsets the process group of the terminal to the process group
7551194Smarcof the started job, waits for the job to complete, and then
7651194Smarcsets the process group of the terminal back to its own process
7751194Smarcgroup (it puts itself into the foreground).  If the job is to
7851194Smarcbe started in the background (as denoted by the shell operator "&"),
7951194Smarcit never changes the process group of the terminal and doesn't
8051194Smarcwait for the job to complete (that is, it immediately attempts to read the next
8151194Smarccommand).  If the job is started in the foreground, the user may
82*55008Scaeltype a key (ususally
83*55008Scael.Ql \&^Z )
84*55008Scaelwhich generates the terminal stop signal
85*55008Scael.Pq Dv SIGTSTP
86*55008Scaeland has the affect of stopping the entire job.
8751194SmarcThe shell will notice that the job stopped, and will resume running after
8851194Smarcplacing itself in the foreground.
8951194SmarcThe shell also has commands for placing stopped jobs in the background,
9051194Smarcand for placing stopped or background jobs into to the foreground.
91*55008Scael.Ss Orphaned Process Groups
9251194SmarcAn orphaned process group is a process group that has no process
9351194Smarcwhose parent is in a different process group, yet is in the same
9451194Smarcsession.  Conceptually it means a process group that doesn't have
9551194Smarca parent that could do anything if it were to be stopped.  For example,
9651194Smarcthe initial login shell is typically in an orphaned process group.
9751194SmarcOrphaned process groups are immune to keyboard generated stop
9851194Smarcsignals and job control signals resulting from reads or writes to the
9951194Smarccontrolling terminal.
100*55008Scael.Ss The Controlling Terminal
10151194SmarcA terminal may belong to a process as its controlling terminal.  Each
10251194Smarcprocess of a session that has a controlling terminal has the same
10351194Smarccontrolling terminal.  A terminal may be the controlling terminal for at
10451194Smarcmost one session.  The controlling terminal for a session is allocated by
105*55008Scaelthe session leader by issuing the
106*55008Scael.Dv TIOCSCTTY
107*55008Scaelioctl.  A controlling terminal
10851194Smarcis never acquired by mereley opening a terminal device file.
10951194SmarcWhen a controlling terminal becomes
110*55008Scaelassociated with a session, its foreground process group is set to
11151194Smarcthe process group of the session leader.
112*55008Scael.Pp
113*55008ScaelThe controlling terminal is inherited by a child process during a
114*55008Scael.Xr fork 2
11551194Smarcfunction call.  A process relinquishes its controlling terminal when it
116*55008Scaelcreates a new session with the
117*55008Scael.Xd setsid 2
118*55008Scaelfunction; other processes
11951194Smarcremaining in the old session that had this terminal as their controlling
120*55008Scaelterminal continue to have it.
12151194SmarcA process does not relinquish its
12251194Smarccontrolling terminal simply by closing all of its file descriptors
12351194Smarcassociated with the controlling terminal if other processes continue to
12451194Smarchave it open.
125*55008Scael.Pp
12651194SmarcWhen a controlling process terminates, the controlling terminal is
12751194Smarcdisassociated from the current session, allowing it to be acquired by a
12851194Smarcnew session leader.  Subsequent access to the terminal by other processes
12951194Smarcin the earlier session will be denied, with attempts to access the
13051194Smarcterminal treated as if modem disconnect had been sensed.
131*55008Scael.Ss Terminal Access Control
13251194SmarcIf a process is in the foreground process group of its controlling
133*55008Scaelterminal, read operations are allowed.
13451194SmarcAny attempts by a process
135*55008Scaelin a background process group to read from its controlling terminal
136*55008Scaelcauses a
137*55008Scael.Dv SIGTTIN
138*55008Scaelsignal to be sent to
139*55008Scaelthe process's group
140*55008Scaelunless one of the
14151194Smarcfollowing special cases apply:  If the reading process is ignoring or
142*55008Scaelblocking the
143*55008Scael.Dv SIGTTIN signal, or if the process group of the reading
144*55008Scaelprocess is orphaned, the
145*55008Scael.Xr read 2
146*55008Scaelreturns -1 with
147*55008Scael.Va errno set to
148*55008Scael.Er Dv EIO
149*55008Scaeland no
150*55008Scaelsignal is sent.  The default action of the
151*55008Scael.Dv SIGTTIN
152*55008Scaelsignal is to stop the
15351194Smarcprocess to which it is sent.
154*55008Scael.Pp
15551194SmarcIf a process is in the foreground process group of its controlling
156*55008Scaelterminal, write operations are allowed.
15751194SmarcAttempts by a process in a background process group to write to its
158*55008Scaelcontrolling terminal will cause the process group to be sent a
159*55008Scael.Dv SIGTTOU
160*55008Scaelsignal unless one of the following special cases apply:  If
161*55008Scael.Dv TOSTOP
162*55008Scaelis not
163*55008Scaelset, or if
164*55008Scael.Dv TOSTOP
165*55008Scaelis set and the process is ignoring or blocking the
166*55008Scael.Dv SIGTTOU
167*55008Scaelsignal, the process is allowed to write to the terminal and the
168*55008Scael.Dv SIGTTOU
169*55008Scaelsignal is not sent.  If
170*55008Scael.Dv TOSTOP
171*55008Scaelis set, and the process group of
17251194Smarcthe writing process is orphaned, and the writing process is not ignoring
173*55008Scaelor blocking
174*55008Scael.Dv SIGTTOU ,
175*55008Scaelthe
176*55008Scael.Xr write
177*55008Scaelreturns -1 with
178*55008Scaelerrno set to
179*55008Scael.Er Dv EIO
180*55008Scaeland no signal is sent.
181*55008Scael.Pp
18251194SmarcCertain calls that set terminal parameters are treated in the same
183*55008Scaelfashion as write, except that
184*55008Scael.Dv TOSTOP
185*55008Scaelis ignored; that is, the effect is
186*55008Scaelidentical to that of terminal writes when
187*55008Scael.Dv TOSTOP
188*55008Scaelis set.
189*55008Scael.Ss Input Processing and Reading Data
19051194SmarcA terminal device associated with a terminal device file may operate in
19151194Smarcfull-duplex mode, so that data may arrive even while output is occurring.
19251194SmarcEach terminal device file has associated with it an input queue, into
19351194Smarcwhich incoming data is stored by the system before being read by a
194*55008Scaelprocess.  The system imposes a limit,
195*55008Scael.Pf \&{ Dv MAX_INPUT Ns \&} ,
196*55008Scaelon the number of
19751194Smarcbytes that may be stored in the input queue.  The behavior of the system
198*55008Scaelwhen this limit is exceeded depends on the setting of the
199*55008Scael.Dv IMAXBEL
200*55008Scaelflag in the termios
201*55008Scael.Fa c_iflag .
202*55008ScaelIf this flag is set, the terminal
203*55008Scaelis a sent an
204*55008Scael.Tn ASCII
205*55008Scael.Dv BEL
206*55008Scaelcharacter each time a character is recieved
20751194Smarcwhile the input queue is full.  Otherwise, the input queue is flushed
20851194Smarcupon receiving the character.
209*55008Scael.Pp
21051194SmarcTwo general kinds of input processing are available, determined by
21151194Smarcwhether the terminal device file is in canonical mode or noncanonical
21251194Smarcmode. Additionally,
213*55008Scaelinput characters are processed according to the
214*55008Scael.Fa c_iflag
215*55008Scaeland
216*55008Scael.Fa c_lflag
217*55008Scaelfields.  Such processing can include echoing, which
21851194Smarcin general means transmitting input characters immediately back to the
21951194Smarcterminal when they are received from the terminal.  This is useful for
22051194Smarcterminals that can operate in full-duplex mode.
221*55008Scael.Pp
22251194SmarcThe manner in which data is provided to a process reading from a terminal
22351194Smarcdevice file is dependent on whether the terminal device file is in
22451194Smarccanonical or noncanonical mode.
225*55008Scael.Pp
226*55008ScaelAnother dependency is whether the
227*55008Scael.Dv O_NONBLOCK
228*55008Scaelflag is set by
229*55008Scael.Xr open()
230*55008Scaelor
231*55008Scael.Xr fcntl() .
232*55008ScaelIf the
233*55008Scael.Dv O_NONBLOCK
234*55008Scaelflag is clear, then the read request is
23551194Smarcblocked until data is available or a signal has been received.  If the
236*55008Scael.Dv O_NONBLOCK
237*55008Scaelflag is set, then the read request is completed, without
23851194Smarcblocking, in one of three ways:
239*55008Scael.Bl -enum -offset indent
240*55008Scael.It
241*55008ScaelIf there is enough data available to satisfy the entire request,
242*55008Scaeland the read completes successfully the number of
243*55008Scaelbytes read is returned.
244*55008Scael.It
245*55008ScaelIf there is not enough data available to satisfy the entire
246*55008Scaelrequest, and the read completes successfully, having read as
247*55008Scaelmuch data as possible, the number of bytes read is returned.
248*55008Scael.It
249*55008ScaelIf there is no data available, the read returns -1, with
250*55008Scaelerrno set to
251*55008Scael.Br EAGAIN .
252*55008Scael.El
253*55008Scael.Pp
25451194SmarcWhen data is available depends on whether the input processing mode is
255*55008Scaelcanonical or noncanonical.
256*55008Scael.Ss Canonical Mode Input Processing
25751194SmarcIn canonical mode input processing, terminal input is processed in units
258*55008Scaelof lines.  A line is delimited by a newline
259*55008Scael.Ql \&\en
260*55008Scaelcharacter, an end-of-file
261*55008Scael.Pq Dv EOF
262*55008Scaelcharacter, or an end-of-line
263*55008Scael.Pq Dv EOL
264*55008Scaelcharacter.  See the
265*55008Scael.Sx "Special Characters"
266*55008Scaelsection for
267*55008Scaelmore information on
268*55008Scael.Dv EOF
269*55008Scaeland
270*55008Scael.Dv EOL .
271*55008ScaelThis means that a read request will
27251194Smarcnot return until an entire line has been typed, or a signal has been
27351194Smarcreceived.  Also, no matter how many bytes are requested in the read call,
274*55008Scaelat most one line is returned.  It is not, however, necessary to
27551194Smarcread a whole line at once; any number of bytes, even one, may be
27651194Smarcrequested in a read without losing information.
277*55008Scael.Pp
278*55008Scael.Pf \&{ Dv MAX_CANON Ns \&}
279*55008Scaelis a limit on the
280*55008Scaelnumber of bytes in a line.
28151194SmarcThe behavior of the system when this limit is
282*55008Scaelexceeded is the same as when the input queue limit
283*55008Scael.Pf \&{ Dv MAX_INPUT Ns \&} ,
284*55008Scaelis exceeded.
285*55008Scael.Pp
28651194SmarcErase and kill processing occur when either of two special characters,
287*55008Scaelthe
288*55008Scael.Dv ERASE
289*55008Scaeland
290*55008Scael.Dv KILL
291*55008Scaelcharacters (see the
292*55008Scael.Sx "Special Characters section" ) ,
293*55008Scaelis received.
29451194SmarcThis processing affects data in the input queue that has not yet been
295*55008Scaeldelimited by a newline
296*55008Scael.Dv NL,
297*55008Scael.Dv EOF ,
298*55008Scaelor
299*55008Scael.Dv EOL
300*55008Scaelcharacter.  This un-delimited
301*55008Scaeldata makes up the current line.  The
302*55008Scael.Dv ERASE
303*55008Scaelcharacter deletes the last
304*55008Scaelcharacter in the current line, if there is any.  The
305*55008Scael.Dv KILL
306*55008Scaelcharacter
307*55008Scaeldeletes all data in the current line, if there is any.  The
308*55008Scael.Dv ERASE
309*55008Scaeland
310*55008Scael.Dv KILL
311*55008Scaelcharacters have no effect if there is no data in the current line.
312*55008ScaelThe
313*55008Scael.Dv ERASE
314*55008Scaeland
315*55008Scael.Dv KILL
316*55008Scaelcharacters themselves are not placed in the input
31751194Smarcqueue.
318*55008Scael.Ss Noncanonical Mode Input Processing
31951194SmarcIn noncanonical mode input processing, input bytes are not assembled into
32051194Smarclines, and erase and kill processing does not occur.  The values of the
321*55008Scael.Dv MIN
322*55008Scaeland
323*55008Scael.Dv TIME
324*55008Scaelmembers of the
325*55008Scael.Fa c_cc
326*55008Scaelarray are used to determine how to
32751194Smarcprocess the bytes received.
328*55008Scael.Pp
329*55008Scael.Dv MIN
330*55008Scaelrepresents the minimum number of bytes that should be received when
331*55008Scaelthe
332*55008Scael.Xr read
333*55008Scaelfunction successfully returns.
334*55008Scael.Dv TIME
335*55008Scaelis a timer of 0.1 second
33651194Smarcgranularity that is used to time out bursty and short term data
337*55008Scaeltransmissions.  If
338*55008Scael.Dv MIN
339*55008Scaelis greater than
340*55008Scael.Dv \&{ Dv MAX_INPUT Ns \&} ,
341*55008Scaelthe response to the
342*55008Scaelrequest is undefined.  The four possible values for
343*55008Scael.Dv MIN
344*55008Scaeland
345*55008Scael.Dv TIME
346*55008Scaeland
34751194Smarctheir interactions are described below.
348*55008Scael.Ss "Case A: MIN > 0, TIME > 0"
349*55008ScaelIn this case
350*55008Scael.Dv TIME
351*55008Scaelserves as an inter-byte timer and is activated after
35251194Smarcthe first byte is received.  Since it is an inter-byte timer, it is reset
353*55008Scaelafter a byte is received.  The interaction between
354*55008Scael.Dv MIN
355*55008Scaeland
356*55008Scael.Dv TIME
357*55008Scaelis as
35851194Smarcfollows:  as soon as one byte is received, the inter-byte timer is
359*55008Scaelstarted.  If
360*55008Scael.Dv MIN
361*55008Scaelbytes are received before the inter-byte timer expires
36251194Smarc(remember that the timer is reset upon receipt of each byte), the read is
363*55008Scaelsatisfied.  If the timer expires before
364*55008Scael.Dv MIN
365*55008Scaelbytes are received, the
36651194Smarccharacters received to that point are returned to the user.  Note that if
367*55008Scael.Dv TIME
368*55008Scaelexpires at least one byte is returned because the timer would
369*55008Scaelnot have been enabled unless a byte was received.  In this case
370*55008Scael.Pf \&( Dv MIN
371*55008Scael> 0,
372*55008Scael.Dv TIME
373*55008Scael> 0) the read blocks until the
374*55008Scael.Dv MIN
375*55008Scaeland
376*55008Scael.Dv TIME
377*55008Scaelmechanisms are
37851194Smarcactivated by the receipt of the first byte, or a signal is received.  If
379*55008Scaeldata is in the buffer at the time of the read(), the result is as
38051194Smarcif data had been received immediately after the read().
381*55008Scael.Ss "Case B: MIN > 0, TIME = 0"
382*55008ScaelIn this case, since the value of
383*55008Scael.Dv TIME
384*55008Scaelis zero, the timer plays no role
385*55008Scaeland only
386*55008Scael.Dv MIN
387*55008Scaelis significant.  A pending read is not satisfied until
388*55008Scael.Dv MIN
389*55008Scaelbytes are received (i.e., the pending read blocks until
390*55008Scael.Dv MIN
391*55008Scaelbytes
39251194Smarcare received), or a signal is received.  A program that uses this case to
393*55008Scaelread record-based terminal
394*55008Scael.Dv I/O
395*55008Scaelmay block indefinitely in the read
39651194Smarcoperation.
397*55008Scael.Ss "Case C: MIN = 0, TIME > 0"
398*55008ScaelIn this case, since
399*55008Scael.Dv MIN
400*55008Scael= 0,
401*55008Scael.Dv TIME
402*55008Scaelno longer represents an inter-byte
40351194Smarctimer.  It now serves as a read timer that is activated as soon as the
404*55008Scaelread function is processed.  A read is satisfied as soon as a single
40551194Smarcbyte is received or the read timer expires.  Note that in this case if
406*55008Scaelthe timer expires, no bytes are returned.  If the timer does not
40751194Smarcexpire, the only way the read can be satisfied is if a byte is received.
408*55008ScaelIn this case the read will not block indefinitely waiting for a byte; if
409*55008Scaelno byte is received within
410*55008Scael.Dv TIME Ns *0.1
411*55008Scaelseconds after the read is initiated,
412*55008Scaelthe read returns a value of zero, having read no data.  If data is
413*55008Scaelin the buffer at the time of the read, the timer is started as if
414*55008Scaeldata had been received immediately after the read.
415*55008Scael.Ss Case D: MIN = 0, TIME = 0
41651194SmarcThe minimum of either the number of bytes requested or the number of
417*55008Scaelbytes currently available is returned without waiting for more
418*55008Scaelbytes to be input.  If no characters are available, read returns a
41951194Smarcvalue of zero, having read no data.
420*55008Scael.Ss Writing Data and Output Processing
42151194SmarcWhen a process writes one or more bytes to a terminal device file, they
422*55008Scaelare processed according to the
423*55008Scael.Fa c_oflag
424*55008Scaelfield (see the
425*55008Scael.Sx "Output Modes
42651194Smarcsection).  The
42751194Smarcimplementation may provide a buffering mechanism; as such, when a call to
42851194Smarcwrite() completes, all of the bytes written have been scheduled for
42951194Smarctransmission to the device, but the transmission will not necessarily
430*55008Scaelhave completed.
431*55008Scael.\" See also .Sx "6.4.2" for the effects of
432*55008Scael.\" .Dv O_NONBLOCK
433*55008Scael.\" on write.
434*55008Scael.Ss Special Characters
43551194SmarcCertain characters have special functions on input or output or both.
43651194SmarcThese functions are summarized as follows:
437*55008Scael.Bl -tag -width indent
438*55008Scael.It Dv INTR
439*55008ScaelSpecial character on input and is recognized if the
440*55008Scael.Dv ISIG
441*55008Scaelflag (see the
442*55008Scael.Sx "Local Modes"
443*55008Scaelsection) is enabled.  Generates a
444*55008Scael.Dv SIGINT
445*55008Scaelsignal which is sent to all processes in the foreground
446*55008Scaelprocess group for which the terminal is the controlling
447*55008Scaelterminal.  If
448*55008Scael.Dv ISIG
449*55008Scaelis set, the
450*55008Scael.Dv INTR
451*55008Scaelcharacter is
452*55008Scaeldiscarded when processed.
453*55008Scael.It Dv QUIT
454*55008ScaelSpecial character on input and is recognized if the
455*55008Scael.Dv ISIG
456*55008Scaelflag is enabled.  Generates a
457*55008Scael.Dv SIGQUIT
458*55008Scaelsignal which is
459*55008Scaelsent to all processes in the foreground process group
460*55008Scaelfor which the terminal is the controlling terminal.  If
461*55008Scael.Dv ISIG
462*55008Scaelis set, the
463*55008Scael.Dv QUIT
464*55008Scaelcharacter is discarded when
465*55008Scaelprocessed.
466*55008Scael.It Dv ERASE
467*55008ScaelSpecial character on input and is recognized if the
468*55008Scael.Dv ICANON
469*55008Scaelflag is set.  Erases the last character in the
470*55008Scaelcurrent line; see
471*55008Scael.Sx "Canonical Mode Input Processing" .
472*55008ScaelIt does not erase beyond
473*55008Scaelthe start of a line, as delimited by an
474*55008Scael.Dv NL ,
475*55008Scael.Dv EOF ,
476*55008Scaelor
477*55008Scael.Dv EOL
478*55008Scaelcharacter.  If
479*55008Scael.Dv ICANON
480*55008Scaelis set, the
481*55008Scael.Dv ERASE
482*55008Scaelcharacter is
483*55008Scaeldiscarded when processed.
484*55008Scael.It Dv KILL
485*55008ScaelSpecial character on input and is recognized if the
486*55008Scael.Dv ICANON
487*55008Scaelflag is set.  Deletes the entire line, as
488*55008Scaeldelimited by a
489*55008Scael.Dv NL ,
490*55008Scael.Dv EOF ,
491*55008Scaelor
492*55008Scael.Dv EOL
493*55008Scaelcharacter.  If
494*55008Scael.Dv ICANON
495*55008Scaelis set, the
496*55008Scael.Dv KILL
497*55008Scaelcharacter is discarded when processed.
498*55008Scael.It Dv EOF
499*55008ScaelSpecial character on input and is recognized if the
500*55008Scael.Dv ICANON
501*55008Scaelflag is set.  When received, all the bytes
502*55008Scaelwaiting to be read are immediately passed to the
503*55008Scaelprocess, without waiting for a newline, and the
504*55008Scael.Dv EOF
505*55008Scaelis discarded.  Thus, if there are no bytes waiting (that
506*55008Scaelis, the
507*55008Scael.Dv EOF
508*55008Scaeloccurred at the beginning of a line), a byte
509*55008Scaelcount of zero is returned from the read(),
510*55008Scaelrepresenting an end-of-file indication.  If
511*55008Scael.Dv ICANON
512*55008Scaelis
513*55008Scaelset, the
514*55008Scael.Dv EOF
515*55008Scaelcharacter is discarded when processed.
516*55008Scael.Dv NL
517*55008ScaelSpecial character on input and is recognized if the
518*55008Scael.Dv ICANON
519*55008Scaelflag is set.  It is the line delimiter
520*55008Scael.Ql \&\en .
521*55008Scael.It Dv EOL
522*55008ScaelSpecial character on input and is recognized if the
523*55008Scael.Dv ICANON
524*55008Scaelflag is set.  Is an additional line delimiter,
525*55008Scaellike
526*55008Scael.Dv NL .
527*55008Scael.It Dv SUSP
528*55008ScaelIf the
529*55008Scael.Dv ISIG
530*55008Scaelflag is enabled, receipt of the
531*55008Scael.Dv SUSP
532*55008Scaelcharacter causes a
533*55008Scael.Dv SIGTSTP
534*55008Scaelsignal to be sent to all processes in the
535*55008Scaelforeground process group for which the terminal is the
536*55008Scaelcontrolling terminal, and the
537*55008Scael.Dv SUSP
538*55008Scaelcharacter is
539*55008Scaeldiscarded when processed.
540*55008Scael.It Dv STOP
541*55008ScaelSpecial character on both input and output and is
542*55008Scaelrecognized if the
543*55008Scael.Dv IXON
544*55008Scael(output control) or
545*55008Scael.Dv IXOFF
546*55008Scael(input
547*55008Scaelcontrol) flag is set.  Can be used to temporarily
548*55008Scaelsuspend output.  It is useful with fast terminals to
549*55008Scaelprevent output from disappearing before it can be read.
550*55008ScaelIf
551*55008Scael.Dv IXON
552*55008Scaelis set, the
553*55008Scael.Dv STOP
554*55008Scaelcharacter is discarded when
555*55008Scaelprocessed.
556*55008Scael.It Dv START
557*55008ScaelSpecial character on both input and output and is
558*55008Scaelrecognized if the
559*55008Scael.Dv IXON
560*55008Scael(output control) or
561*55008Scael.Dv IXOFF
562*55008Scael(input
563*55008Scaelcontrol) flag is set.  Can be used to resume output that
564*55008Scaelhas been suspended by a
565*55008Scael.Dv STOP
566*55008Scaelcharacter.  If
567*55008Scael.Dv IXON
568*55008Scaelis set, the
569*55008Scael.Dv START
570*55008Scaelcharacter is discarded when processed.
571*55008Scael.Dv CR
572*55008ScaelSpecial character on input and is recognized if the
573*55008Scael.Dv ICANON
574*55008Scaelflag is set; it is the
575*55008Scael.Ql \&\er ,
576*55008Scaelas denoted in the
577*55008Scael.Tn \&C
578*55008ScaelStandard {2}.  When
579*55008Scael.Dv ICANON
580*55008Scaeland
581*55008Scael.Dv ICRNL
582*55008Scaelare set and
583*55008Scael.Dv IGNCR
584*55008Scaelis not set, this character is translated into a
585*55008Scael.Dv NL ,
586*55008Scaeland
587*55008Scaelhas the same effect as a
588*55008Scael.Dv NL
589*55008Scaelcharacter.
590*55008Scael.El
591*55008Scael.Pp
59251194SmarcThe following special characters are extensions defined by this
59351194Smarcsystem and are not a part of 1003.1 termios.
594*55008Scael.Bl -tag -width indent
595*55008Scael.It Dv EOL2
596*55008ScaelSecondary
597*55008Scael.Dv EOL
598*55008Scaelcharacter.  Same function as
599*55008Scael.Dv EOL.
600*55008Scael.It Dv WERASE
601*55008ScaelSpecial character on input and is recognized if the
602*55008Scael.Dv ICANON
603*55008Scaelflag is set.  Erases the last word in the current
604*55008Scaelline according to one of two algorithms.  If the
605*55008Scael.Dv ALTWERASE
606*55008Scaelflag is not set, first any preceding whitespace is
607*55008Scaelerased, and then the maximal sequence of non-whitespace
608*55008Scaelcharacters.  If
609*55008Scael.Dv ALTWERASE
610*55008Scaelis set, first any preceding
611*55008Scaelwhitespace is erased, and then the maximal sequence
612*55008Scaelof alphabetic/underscores or non alphabetic/underscores.
613*55008ScaelAs a special case in this second algorithm, the first previous
614*55008Scaelnon-whitespace character is skippied in determining
615*55008Scaelwhether the preceding word is a sequence of
616*55008Scaelalphabetic/undercores.  This sounds confusing but turns
617*55008Scaelout to be quite practical.
618*55008Scael.It Dv REPRINT
619*55008ScaelSpecial character on input and is recognized if the
620*55008Scael.Dv ICANON
621*55008Scaelflag is set.  Causes the current input edit line
622*55008Scaelto be retyped.
623*55008Scael.It Dv DSUSP
624*55008ScaelHas similar actions to the
625*55008Scael.Dv SUSP
626*55008Scaelcharacter, except that
627*55008Scaelthe
628*55008Scael.Dv SIGTSTP
629*55008Scaelsignal is delivered when one of the processes
630*55008Scaelin the foreground process group issues a read() to the
631*55008Scaelcontrolling terminal.
632*55008Scael.It Dv LNEXT
633*55008ScaelSpecial character on input and is recognized if the
634*55008Scael.Dv IEXTEN
635*55008Scaelflag is set.  Receipt of this character causes the next
636*55008Scaelcharacter to be taken literally.
637*55008Scael.It Dv DISCARD
638*55008ScaelSpecial character on input and is recognized if the
639*55008Scael.Dv IEXTEN
640*55008Scaelflag is set.  Receipt of this character toggles the flushing
641*55008Scaelof terminal output.
642*55008Scael.It Dv STATUS
643*55008ScaelSpecial character on input and is recognized if the
644*55008Scael.Dv ICANON
645*55008Scaelflag is set.  Receipt of this character causes a
646*55008Scael.Dv SIGINFO
647*55008Scaelsignal to be sent to the forground process group of the
648*55008Scaelterminal.  Also, if the
649*55008Scael.Dv NOKERNINFO
650*55008Scaelflag is not set, it
651*55008Scaelcauses the kernel to write a status message to the terminal
652*55008Scaelthat displays the current load average, the name of the
653*55008Scaelcommand in the foreground, its process ID, the symbolic
654*55008Scaelwait channel, the number of user and system seconds used,
655*55008Scaelthe percentage of cpu the process is getting, and the resident
656*55008Scaelset size of the process.
657*55008Scael.El
658*55008Scael.Pp
659*55008ScaelThe
660*55008Scael.Dv NL
661*55008Scaeland
662*55008Scael.Dv CR
663*55008Scaelcharacters cannot be changed.
66451194SmarcThe values for all the remaining characters can be set and are
665*55008Scaeldescribed later in the document under
666*55008ScaelSpecial Control Characters.
667*55008Scael.Pp
66851194SmarcSpecial
66951194Smarccharacter functions associated with changeable special control characters
670*55008Scaelcan be disabled individually by setting their value to
671*55008Scael.Dv {_POSIX_VDISABLE};
672*55008Scaelsee
673*55008Scael.Sx "Special Control Characters" .
674*55008Scael.Pp
67551194SmarcIf two or more special characters have the same value, the function
67651194Smarcperformed when that character is received is undefined.
677*55008Scael.Ss Modem Disconnect
67851194SmarcIf a modem disconnect is detected by the terminal interface for a
679*55008Scaelcontrolling terminal, and if
680*55008Scael.Dv CLOCAL
681*55008Scaelis not set in the
682*55008Scael.Fa c_cflag
683*55008Scaelfield for
684*55008Scaelthe terminal, the
685*55008Scael.Dv SIGHUP
686*55008Scaelsignal is sent to the controlling
68751194Smarcprocess associated with the terminal.  Unless other arrangements have
68851194Smarcbeen made, this causes the controlling process to terminate.
689*55008ScaelAny subsequent call to the read() function return the value zero,
69051194Smarcindicating end of file.  Thus, processes that read a terminal
69151194Smarcfile and test for end-of-file can terminate appropriately after a
692*55008Scaeldisconnect.
693*55008Scael.\" If the
694*55008Scael.\" .Er EIO
695*55008Scael.\" condition specified in 6.1.1.4 that applies
696*55008Scael.\" when the implementation supports job control also exists, it is
697*55008Scael.\" unspecified whether the
698*55008Scael.\" .Dv EOF
699*55008Scael.\" condition or the
700*55008Scael.\" .Pf [ Dv EIO
701*55008Scael.\" ] is returned.
702*55008ScaelAny
703*55008Scaelsubsequent write() to the terminal device returns -1, with
704*55008Scael.Va errno
705*55008Scaelset to
706*55008Scael.Er EIO ,
707*55008Scaeluntil the device is closed.
708*55008Scael.Sh General Terminal Interface
709*55008Scael.Pp
710*55008Scael.Ss Closing a Terminal Device File
711*55008ScaelThe last process to close a terminal device file causes any output
712*55008Scaelto be sent to the device and any input to be discarded.  Then, if
713*55008Scael.Dv HUPCL
71451194Smarcis set in the control modes, and the communications port supports a
715*55008Scaeldisconnect function, the terminal device performs a disconnect.
716*55008Scael.Ss Parameters That Can Be Set
717*55008ScaelRoutines that need to control certain terminal
718*55008Scael.Tn I/O
719*55008Scaelcharacteristics
72051194Smarcdo so by using the termios structure as defined in the header
721*55008Scael.Aq Pa termios.h .
72251194SmarcThis structure contains minimally four scalar elements of bit flags
72351194Smarcand one array of special characters.  The scalar flag elements are
724*55008Scaelnamed:
725*55008Scael.Fa c_iflag ,
726*55008Scael.Fa c_oflag ,
727*55008Scael.Fa c_cflag ,
728*55008Scaeland
729*55008Scael.Fa c_lflag .  The character array
730*55008Scaelis named
731*55008Scael.Fa c_cc ,
732*55008Scaeland its maximum index is
733*55008Scael.Dv NCCS .
734*55008Scael.Ss Input Modes
735*55008ScaelValues of the
736*55008Scael.Fa c_iflag
737*55008Scaelfield describe the basic
73851194Smarcterminal input control, and are composed of
739*55008Scaelfollowing masks:
740*55008Scael.Pp
741*55008Scael.Bl -tag -width IMAXBEL -offset indent -compact
742*55008Scael.It Dv IGNBRK
743*55008Scael/* ignore BREAK condition */
744*55008Scael.It Dv BRKINT
745*55008Scael/* map BREAK to SIGINTR */
746*55008Scael.It Dv IGNPAR
747*55008Scael/* ignore (discard) parity errors */
748*55008Scael.It Dv PARMRK
749*55008Scael/* mark parity and framing errors */
750*55008Scael.It Dv INPCK
751*55008Scael/* enable checking of parity errors */
752*55008Scael.It Dv ISTRIP
753*55008Scael/* strip 8th bit off chars */
754*55008Scael.It Dv INLCR
755*55008Scael/* map NL into CR */
756*55008Scael.It Dv IGNCR
757*55008Scael/* ignore CR */
758*55008Scael.It Dv ICRNL
759*55008Scael/* map CR to NL (ala CRMOD) */
760*55008Scael.It Dv IXON
761*55008Scael/* enable output flow control */
762*55008Scael.It Dv IXOFF
763*55008Scael/* enable input flow control */
764*55008Scael.It Dv IXANY
765*55008Scael/* any char will restart after stop */
766*55008Scael.It Dv IMAXBEL
767*55008Scael/* ring bell on input queue full */
768*55008Scael.El
769*55008Scael.Pp
77051194SmarcIn the context of asynchronous serial data transmission, a break
77151194Smarccondition is defined as a sequence of zero-valued bits that continues for
77251194Smarcmore than the time to send one byte.  The entire sequence of zero-valued
77351194Smarcbits is interpreted as a single break condition, even if it continues for
77451194Smarca time equivalent to more than one byte.  In contexts other than
77551194Smarcasynchronous serial data transmission the definition of a break condition
77651194Smarcis implementation defined.
777*55008Scael.Pp
778*55008ScaelIf
779*55008Scael.Dv IGNBRK
780*55008Scaelis set, a break condition detected on input is ignored, that
78151194Smarcis, not put on the input queue and therefore not read by any process.  If
782*55008Scael.Dv IGNBRK
783*55008Scaelis not set and
784*55008Scael.Dv BRKINT
785*55008Scaelis set, the break condition flushes the
78651194Smarcinput and output queues and if the terminal is the controlling terminal
787*55008Scaelof a foreground process group, the break condition generates a
788*55008Scaelsingle
789*55008Scael.Dv SIGINT
790*55008Scaelsignal to that foreground process group.  If neither
791*55008Scael.Dv IGNBRK
792*55008Scaelnor
793*55008Scael.Dv BRKINT
794*55008Scaelis set, a break condition is read as a single
795*55008Scael.Ql \&\e0 ,
796*55008Scaelor if
797*55008Scael.Dv PARMRK
798*55008Scaelis set, as
799*55008Scael.Ql \&\e377 ,
800*55008Scael.Ql \&\e0 ,
801*55008Scael.Ql \&\e0 .
802*55008Scael.Pp
803*55008ScaelIf
804*55008Scael.Dv IGNPAR
805*55008Scaelis set, a byte with a framing or parity error (other than
80651194Smarcbreak) is ignored.
807*55008Scael.Pp
808*55008ScaelIf
809*55008Scael.Dv PARMRK
810*55008Scaelis set, and
811*55008Scael.Dv IGNPAR
812*55008Scaelis not set, a byte with a framing or parity
81351194Smarcerror (other than break) is given to the application as the three-
814*55008Scaelcharacter sequence
815*55008Scael.Ql \&\e377 ,
816*55008Scael.Ql \&\e0 ,
817*55008ScaelX, where
818*55008Scael.Ql \&\e377 ,
819*55008Scael.Ql \&\e0
820*55008Scaelis a two-character
82151194Smarcflag preceding each sequence and X is the data of the character received
822*55008Scaelin error.  To avoid ambiguity in this case, if
823*55008Scael.Dv ISTRIP
824*55008Scaelis not set, a valid
825*55008Scaelcharacter of
826*55008Scael.Ql \&\e377
827*55008Scaelis given to the application as
828*55008Scael.Ql \&\e377 ,
829*55008Scael.Ql \&\e377 .
830*55008ScaelIf
831*55008Scaelneither
832*55008Scael.Dv PARMRK
833*55008Scaelnor
834*55008Scael.Dv IGNPAR
835*55008Scaelis set, a framing or parity error (other than
836*55008Scaelbreak) is given to the application as a single character
837*55008Scael.Ql \&\e0 .
838*55008Scael.Pp
839*55008ScaelIf
840*55008Scael.Dv INPCK
841*55008Scaelis set, input parity checking is enabled.  If
842*55008Scael.Dv INPCK
843*55008Scaelis not set,
84451194Smarcinput parity checking is disabled, allowing output parity generation
84551194Smarcwithout input parity errors.  Note that whether input parity checking is
84651194Smarcenabled or disabled is independent of whether parity detection is enabled
847*55008Scaelor disabled (see
848*55008Scael.Sx "Control Modes" ) .
849*55008ScaelIf parity detection is enabled but input
85051194Smarcparity checking is disabled, the hardware to which the terminal is
851*55008Scaelconnected recognizes the parity bit, but the terminal special file
852*55008Scaeldoes not check whether this bit is set correctly or not.
853*55008Scael.Pp
854*55008ScaelIf
855*55008Scael.Dv ISTRIP
856*55008Scaelis set, valid input bytes are first stripped to seven bits,
85751194Smarcotherwise all eight bits are processed.
858*55008Scael.Pp
859*55008ScaelIf
860*55008Scael.Dv INLCR
861*55008Scaelis set, a received
862*55008Scael.Dv NL character is translated into a
863*55008Scael.Dv CR
864*55008Scaelcharacter.  If
865*55008Scael.Dv IGNCR
866*55008Scaelis set, a received
867*55008Scael.Dv CR
868*55008Scaelcharacter is ignored (not
869*55008Scaelread).  If
870*55008Scael.Dv IGNCR
871*55008Scaelis not set and
872*55008Scael.Dv ICRNL
873*55008Scaelis set, a received
874*55008Scael.Dv CR
875*55008Scaelcharacter is
876*55008Scaeltranslated into a
877*55008Scael.Dv NL
878*55008Scaelcharacter.
879*55008Scael.Pp
880*55008ScaelIf
881*55008Scael.Dv IXON
882*55008Scaelis set, start/stop output control is enabled.  A received
883*55008Scael.Dv STOP
884*55008Scaelcharacter suspends output and a received
885*55008Scael.Dv START
886*55008Scaelcharacter
887*55008Scaelrestarts output. If
888*55008Scael.Dv IXANY
889*55008Scaelis also set, then any character may
890*55008Scaelrestart output. When
891*55008Scael.Dv IXON
892*55008Scaelis set,
893*55008Scael.Dv START
894*55008Scaeland
895*55008Scael.Dv STOP
896*55008Scaelcharacters are not
897*55008Scaelread, but merely perform flow control functions.  When
898*55008Scael.Dv IXON
899*55008Scaelis not set,
900*55008Scaelthe
901*55008Scael.Dv START
902*55008Scaeland
903*55008Scael.Dv STOP
904*55008Scaelcharacters are read.
905*55008Scael.Pp
906*55008ScaelIf
907*55008Scael.Dv IXOFF
908*55008Scaelis set, start/stop input control is enabled.  The system shall
909*55008Scaeltransmit one or more
910*55008Scael.Dv STOP
911*55008Scaelcharacters, which are intended to cause the
91251194Smarcterminal device to stop transmitting data, as needed to prevent the input
91351194Smarcqueue from overflowing and causing the undefined behavior described in
914*55008Scael.Sx "Input Processing and Reading Data" ,
915*55008Scaeland shall transmit one or more
916*55008Scael.Dv START
917*55008Scaelcharacters, which are
91851194Smarcintended to cause the terminal device to resume transmitting data, as
91951194Smarcsoon as the device can continue transmitting data without risk of
920*55008Scaeloverflowing the input queue.  The precise conditions under which
921*55008Scael.Dv STOP
922*55008Scaeland
923*55008ScaelSTART
924*55008Scaelcharacters are transmitted are implementation defined.
925*55008Scael.Pp
926*55008ScaelIf
927*55008Scael.Dv IMAXBEL
928*55008Scaelis set and the input queue is full, subsequent input
929*55008Scaelshall causes an
930*55008Scael.Tn ASCII
931*55008Scael.Dv BEL
932*55008Scaelcharacter to be transmitted to the
93351194Smarcthe output queue.
934*55008Scael.Pp
93551194SmarcThe initial input control value after open() is implementation defined.
936*55008Scael.Ss Output Modes
937*55008ScaelValues of the
938*55008Scael.Fa c_oflag
939*55008Scaelfield describe the basic terminal output control,
94051194Smarcand are composed of the following masks:
941*55008Scael.Pp
942*55008Scael.Bl -tag -width OXTABS -offset indent -compact
943*55008Scael.It Dv OPOST
944*55008Scael/* enable following output processing */
945*55008Scael.It Dv ONLCR
946*55008Scael/* map NL to CR-NL (ala
947*55008Scael.Dv CRMOD)
948*55008Scael*/
949*55008Scael.It Dv OXTABS
950*55008Scael/* expand tabs to spaces */
951*55008Scael.It Dv ONOEOT
952*55008Scael/* discard
953*55008Scael.Dv EOT Ns 's
954*55008Scael.Ql \&^D
955*55008Scaelon output) */
956*55008Scael.El
957*55008Scael.Pp
958*55008ScaelIf
959*55008Scael.Dv OPOST
960*55008Scaelis set, the remaining flag masks are interpreted as follows;
96151194Smarcotherwise characters are transmitted without change.
962*55008Scael.Pp
963*55008ScaelIf
964*55008Scael.Dv ONLCR
965*55008Scaelis set, newlines are translated to carriage return, linefeeds.
966*55008Scael.Pp
967*55008ScaelIf
968*55008Scael.Dv OXTABS
969*55008Scaelis set, tabs are expanded to the appropiate number of
97051194Smarcspaces (assuming 8 column tab stops).
971*55008Scael.Pp
972*55008ScaelIf
973*55008Scael.Dv ONOEOT
974*55008Scaelis set,
975*55008Scael.Tn ASCII
976*55008Scael.Dv EOT NS 's
977*55008Scaelare discarded on output.
978*55008Scael.Ss Control Modes
979*55008ScaelValues of the
980*55008Scael.Fa c_cflag
981*55008Scaelfield describe the basic
982*55008Scaelterminal hardware control, and are composed of the
98351194Smarcthe following masks.
98451194SmarcNot all values
98551194Smarcspecified are supported by all hardware.
986*55008Scael.Pp
987*55008Scael.Bl -tag -width CRTS_IFLOW -offset indent -compact
988*55008Scael.It Dv CSIZE
989*55008Scael/* character size mask */
990*55008Scael.It Dv CS5
991*55008Scael/* 5 bits (pseudo) */
992*55008Scael.It Dv CS6
993*55008Scael/* 6 bits */
994*55008Scael.It Dv CS7
995*55008Scael/* 7 bits */
996*55008Scael.It Dv CS8
997*55008Scael/* 8 bits */
998*55008Scael.It Dv CSTOPB
999*55008Scael/* send 2 stop bits */
1000*55008Scael.It Dv CREAD
1001*55008Scael/* enable receiver */
1002*55008Scael.It Dv PARENB
1003*55008Scael/* parity enable */
1004*55008Scael.It Dv PARODD
1005*55008Scael/* odd parity, else even */
1006*55008Scael.It Dv HUPCL
1007*55008Scael/* hang up on last close */
1008*55008Scael.It Dv CLOCAL
1009*55008Scael/* ignore modem status lines */
1010*55008Scael.It Dv CCTS_OFLOW
1011*55008Scael/*
1012*55008Scael.Dv CTS
1013*55008Scaelflow control of output */
1014*55008Scael.It Dv CRTSCTS
1015*55008Scael/* same as
1016*55008Scael.Dv CCTS_OFLOW
1017*55008Scael*/
1018*55008Scael.It Dv CRTS_IFLOW
1019*55008Scael/* RTS flow control of input */
1020*55008Scael.It Dv MDMBUF
1021*55008Scael/* flow control output via Carrier */
1022*55008Scael.El
1023*55008Scael.Pp
1024*55008ScaelThe
1025*55008Scael.Dv CSIZE
1026*55008Scaelbits specify the byte size in bits for both transmission and
1027*55008Scaelreception.  The
1028*55008Scael.Fa c_cflag
1029*55008Scaelis masked with
1030*55008Scael.Dv CSIZE
1031*55008Scaeland compared with the
1032*55008Scaelvalues
1033*55008Scael.Dv CS5 ,
1034*55008Scael.Dv CS6 ,
1035*55008Scael.Dv CS7 ,
1036*55008Scaelor
1037*55008Scael.Dv CS8 .
1038*55008ScaelThis size does not include the parity bit, if any.  If
1039*55008Scael.Dv CSTOPB
104051194Smarcis set, two stop bits are used, otherwise one stop bit.  For example, at
104151194Smarc110 baud, two stop bits are normally used.
1042*55008Scael.Pp
1043*55008ScaelIf
1044*55008Scael.Dv CREAD
1045*55008Scaelis set, the receiver is enabled.  Otherwise, no characters shall
104651194Smarcbe received.  Not all hardware supports this bit.  In fact, this flag
1047*55008Scaelis pretty silly and if it were not part of the
1048*55008Scael.Nm termios
1049*55008Scaelspecification
105051194Smarcit would be ommitted.
1051*55008Scael.Pp
1052*55008ScaelIf
1053*55008Scael.Dv PARENB
1054*55008Scaelis set, parity generation and detection is enabled and a parity
1055*55008Scaelbit is added to each character.  If parity is enabled,
1056*55008Scael.Dv PARODD
1057*55008Scaelspecifies
105851194Smarcodd parity if set, otherwise even parity is used.
1059*55008Scael.Pp
1060*55008ScaelIf
1061*55008Scael.Dv HUPCL
1062*55008Scaelis set, the modem control lines for the port shall be lowered
106351194Smarcwhen the last process with the port open closes the port or the process
106451194Smarcterminates.  The modem connection shall be broken.
1065*55008Scael.Pp
1066*55008ScaelIf
1067*55008Scael.Dv CLOCAL
1068*55008Scaelis set, a connection does not depend on the state of the modem
1069*55008Scaelstatus lines.  If
1070*55008Scael.Dv CLOCAL
1071*55008Scaelis clear, the modem status lines shall be
107251194Smarcmonitored.
1073*55008Scael.Pp
107451194SmarcUnder normal circumstances, a call to the open() function shall wait for
1075*55008Scaelthe modem connection to complete.  However, if the
1076*55008Scael.Dv O_NONBLOCK
1077*55008Scaelflag is set
1078*55008Scaelor if
1079*55008Scael.Dv CLOCAL
1080*55008Scaelhas been set, the open() function shall return
108151194Smarcimmediately without waiting for the connection.
1082*55008Scael.Pp
1083*55008ScaelThe
1084*55008Scael.Dv CCTS_OFLOW
1085*55008Scael.Pf ( Dv CRTSCTS )
1086*55008Scaelflag is currently unused.
1087*55008Scael.Pp
1088*55008ScaelIf
1089*55008Scael.Dv MDMBUF
1090*55008Scaelis set then output flow control is controlled by the state
109151194Smarcof Carrier Detect.
1092*55008Scael.Pp
109351194SmarcIf the object for which the control modes are set is not an asynchronous
109451194Smarcserial connection, some of the modes may be ignored; for example, if an
109551194Smarcattempt is made to set the baud rate on a network connection to a
109651194Smarcterminal on another host, the baud rate may or may not be set on the
109751194Smarcconnection between that terminal and the machine it is directly connected
109851194Smarcto.
1099*55008Scael.Ss Local Modes
110051194SmarcValues of the c_lflag field describe the control of
110151194Smarcvarious functions, and are composed of the following
1102*55008Scaelmasks.
1103*55008Scael.Pp
1104*55008Scael.Bl -tag -width NOKERNINFO -offset indent -compact
1105*55008Scael.It Dv ECHOKE
1106*55008Scael/* visual erase for line kill */
1107*55008Scael.It Dv ECHOE
1108*55008Scael/* visually erase chars */
1109*55008Scael.It Dv ECHO
1110*55008Scael/* enable echoing */
1111*55008Scael.It Dv ECHONL
1112*55008Scael/* echo
1113*55008Scael.Dv NL
1114*55008Scaeleven if
1115*55008Scael.Dv ECHO
1116*55008Scaelis off */
1117*55008Scael.It Dv ECHOPRT
1118*55008Scael/* visual erase mode for hardcopy */
1119*55008Scael.It Dv ECHOCTL
1120*55008Scael/* echo control chars as ^(Char) */
1121*55008Scael.It Dv ISIG
1122*55008Scael/* enable signals
1123*55008Scael.Dv INTR ,
1124*55008Scael.Dv QUIT ,
1125*55008Scael.Dv [D]SUSP
1126*55008Scael*/
1127*55008Scael.It Dv ICANON
1128*55008Scael/* canonicalize input lines */
1129*55008Scael.It Dv ALTWERASE
1130*55008Scael/* use alternate
1131*55008Scael.Dv WERASE
1132*55008Scaelalgorithm */
1133*55008Scael.It Dv IEXTEN
1134*55008Scael/* enable
1135*55008Scael.Dv DISCARD
1136*55008Scaeland
1137*55008Scael.Dv LNEXT
1138*55008Scael*/
1139*55008Scael.It Dv EXTPROC
1140*55008Scael/* external processing */
1141*55008Scael.It Dv TOSTOP
1142*55008Scael/* stop background jobs from output */
1143*55008Scael.It Dv FLUSHO
1144*55008Scael/* output being flushed (state) */
1145*55008Scael.It Dv NOKERNINFO
1146*55008Scael/* no kernel output from
1147*55008Scael.Dv VSTATUS
1148*55008Scael*/
1149*55008Scael.It Dv PENDIN
1150*55008Scael/* XXX retype pending input (state) */
1151*55008Scael.It Dv NOFLSH
1152*55008Scael/* don't flush after interrupt */
1153*55008Scael.El
1154*55008Scael.Pp
1155*55008ScaelIf
1156*55008Scael.Dv ECHO
1157*55008Scaelis set, input characters are echoed back to the terminal.  If
1158*55008Scael.Dv ECHO
1159*55008Scaelis not set, input characters are not echoed.
1160*55008Scael.Pp
1161*55008ScaelIf
1162*55008Scael.Dv ECHOE
1163*55008Scaeland
1164*55008Scael.Dv ICANON
1165*55008Scaelare set, the
1166*55008Scael.Dv ERASE
1167*55008Scaelcharacter shall cause the terminal
116851194Smarcto erase the last character in the current line from the display, if
116951194Smarcpossible.  If there is no character to erase, an implementation may echo
117051194Smarcan indication that this was the case or do nothing.
1171*55008Scael.Pp
1172*55008ScaelIf
1173*55008Scael.Dv ECHOK
1174*55008Scaeland
1175*55008Scael.Dv ICANON
1176*55008Scaelare set, the
1177*55008Scael.Dv KILL
1178*55008Scaelcharacter shall
117951194Smarccause the current line to be discarded and the system shall
1180*55008Scaelecho the
1181*55008Scael.Ql \&\en
1182*55008Scaelcharacter after the
1183*55008Scael.Dv KILL
1184*55008Scaelcharacter.
1185*55008Scael.Pp
1186*55008ScaelIf
1187*55008Scael.Dv ECHOKE
1188*55008Scaeland
1189*55008Scael.Dv ICANON
1190*55008Scaelare set, the
1191*55008Scael.Dv KILL
1192*55008Scaelcharacter shall cause
119351194Smarcthe current line to be discarded and the system shall cause
119451194Smarcthe terminal
119551194Smarcto erase the line from the display.
1196*55008Scael.Pp
1197*55008ScaelIf
1198*55008Scael.Dv ECHOPRT
1199*55008Scaeland
1200*55008Scael.Dv ICANON
1201*55008Scaelare set, the system shall assume
120251194Smarcthat the display is a printing device and shall print a
1203*55008Scaelbackslash and the erased characters when processing
1204*55008Scael.Dv ERASE
120551194Smarccharacters, followed by a forward slash.
1206*55008Scael.Pp
1207*55008ScaelIf
1208*55008Scael.Dv ECHOCTL
1209*55008Scaelis set, the system shall echo control characters
121051194Smarcin a visible fashion using a carrot followed by the control character.
1211*55008Scael.Pp
1212*55008ScaelIf
1213*55008Scael.Dv ALTWERASE
1214*55008Scaelis set, the system will use an alternative algorithm
1215*55008Scaelfor determining what constitutes a word when processing
1216*55008Scael.Dv WERASE
1217*55008Scaelcharacters (see
1218*55008Scael.Dv WERASE ) .
1219*55008Scael.Pp
1220*55008ScaelIf
1221*55008Scael.Dv ECHONL
1222*55008Scaeland
1223*55008Scael.Dv ICANON
1224*55008Scaelare set, the
1225*55008Scael.Ql \&\en
1226*55008Scaelcharacter shall be echoed even if
1227*55008Scael.Dv ECHO
1228*55008Scaelis not set.
1229*55008Scael.Pp
1230*55008ScaelIf
1231*55008Scael.Dv ICANON
1232*55008Scaelis set, canonical processing is enabled.  This enables the
123351194Smarcerase and kill edit functions, and the assembly of input characters into
1234*55008Scaellines delimited by
1235*55008Scael.Dv NL,
1236*55008Scael.Dv EOF ,
1237*55008Scaeland
1238*55008Scael.Dv EOL,
1239*55008Scaelas described in
1240*55008Scael.Sx "Canonical Mode Input Processing" .
1241*55008Scael.Pp
1242*55008ScaelIf
1243*55008Scael.Dv ICANON
1244*55008Scaelis not set, read requests are satisfied directly from the input
1245*55008Scaelqueue.  A read shall not be satisfied until at least
1246*55008Scael.Dv MIN
1247*55008Scaelbytes have been
1248*55008Scaelreceived or the timeout value
1249*55008Scael.Dv TIME
1250*55008Scaelexpired between bytes.  The time value
1251*55008Scaelrepresents tenths of seconds.  See
1252*55008Scael.Sx "Noncanonical Mode Input Processing"
125351194Smarcfor more details.
1254*55008Scael.Pp
1255*55008ScaelIf
1256*55008Scael.Dv ISIG
1257*55008Scaelis set, each input character is checked against the special
1258*55008Scaelcontrol characters
1259*55008Scael.Dv INTR ,
1260*55008Scael.Dv QUIT ,
1261*55008Scaeland
1262*55008Scael.Dv SUSP
1263*55008Scael(job control only).  If an input
126451194Smarccharacter matches one of these control characters, the function
1265*55008Scaelassociated with that character is performed.  If
1266*55008Scael.Dv ISIG
1267*55008Scaelis not set, no
126851194Smarcchecking is done.  Thus these special input functions are possible only
1269*55008Scaelif
1270*55008Scael.Dv ISIG
1271*55008Scaelis set.
1272*55008Scael.Pp
1273*55008ScaelIf
1274*55008Scael.Dv IEXTEN
1275*55008Scaelis set, implementation-defined functions shall be recognized
1276*55008Scaelfrom the input data.  It is implementation defined how
1277*55008Scael.Dv IEXTEN
1278*55008Scaelbeing set
1279*55008Scaelinteracts with
1280*55008Scael.Dv ICANON ,
1281*55008Scael.Dv ISIG ,
1282*55008Scael.Dv IXON ,
1283*55008Scaelor
1284*55008Scael.Dv IXOFF .
1285*55008ScaelIf
1286*55008Scael.Dv IEXTEN
1287*55008Scaelis not set, then
128851194Smarcimplementation-defined functions shall not be recognized, and the
128951194Smarccorresponding input characters shall be processed as described for
1290*55008Scael.Dv ICANON ,
1291*55008Scael.Dv ISIG ,
1292*55008Scael.Dv IXON ,
1293*55008Scaeland
1294*55008Scael.Dv IXOFF .
1295*55008Scael.Pp
1296*55008ScaelIf
1297*55008Scael.Dv NOFLSH
1298*55008Scaelis set, the normal flush of the input and output queues
1299*55008Scaelassociated with the
1300*55008Scael.Dv INTR ,
1301*55008Scael.Dv QUIT ,
1302*55008Scaeland
1303*55008Scael.Dv SUSP
1304*55008Scaelcharacters
130551194Smarcshall not be done.
1306*55008Scael.Pp
1307*55008ScaelIf
1308*55008Scael.Dv TOSTOP
1309*55008Scaelis set, the signal
1310*55008Scael.Dv SIGTTOU
1311*55008Scaelis sent to the process group of a process that tries to write to
131251194Smarcits controlling terminal if it is not in the foreground process group for
131351194Smarcthat terminal.  This signal, by default, stops the members of the process
131451194Smarcgroup.  Otherwise, the output generated by that process is output to the
1315*55008Scaelcurrent output stream.  Processes that are blocking or ignoring
1316*55008Scael.Dv SIGTTOU
1317*55008Scaelsignals are excepted and allowed to produce output and the
1318*55008Scael.Dv SIGTTOU
1319*55008Scaelsignal
132051194Smarcis not sent.
1321*55008Scael.Pp
1322*55008ScaelIf
1323*55008Scael.Dv NOKERNINFO
1324*55008Scaelis set, the kernel shall not produce a status message
1325*55008Scaelwhen processing
1326*55008Scael.Dv STATUS
1327*55008Scaelcharacters (see
1328*55008Scael.Dv STATUS ) .
1329*55008Scael.Ss Special Control Characters
1330*55008ScaelThe special control characters values are defined by the array c_cc.
133151194SmarcThis table lists the array index, the corresponding special character,
133251194Smarcand the system default value.  For an accurate list of
1333*55008Scaelthe system defaults, consult the header file
1334*55008Scael.Aq Pa ttydefaults.h .
1335*55008Scael.Pp
1336*55008Scael.Bl -column "Index Name" "Special Character" -offset indent -compact
1337*55008Scael.It Em "Index Name	Special Character	Default Value"
1338*55008Scael.It Dv VEOF Ta EOF Ta \&^D
1339*55008Scael.It Dv VEOL Ta EOL Ta _POSIX_VDISABLE
1340*55008Scael.It Dv VEOL2 Ta EOL2 Ta _POSIX_VDISABLE
1341*55008Scael.It Dv VERASE Ta ERASE Ta \&^? Ql \&\e177
1342*55008Scael.It Dv VWERASE  Ta WERASE Ta \&^W
1343*55008Scael.It Dv VKILL Ta KILL Ta \&^U
1344*55008Scael.It Dv VREPRINT Ta REPRINT Ta \&^R
1345*55008Scael.It Dv VINTR Ta INTR Ta \&^C
1346*55008Scael.It Dv VQUIT Ta QUIT Ta \&^\e\e Ql \&\e34
1347*55008Scael.It Dv VSUSP Ta SUSP Ta \&^Z
1348*55008Scael.It Dv VDSUSP Ta DSUSP Ta \&^Y
1349*55008Scael.It Dv VSTART Ta START Ta \&^Q
1350*55008Scael.It Dv VSTOP Ta STOP Ta \&^S
1351*55008Scael.It Dv VLNEXT Ta LNEXT Ta \&^V
1352*55008Scael.It Dv VDISCARD Ta DISCARD Ta \&^O
1353*55008Scael.It Dv VMIN Ta --- Ta \&1
1354*55008Scael.It Dv VTIME Ta --- Ta \&0
1355*55008Scael.It Dv VSTATUS Ta STATUS Ta \&^T
1356*55008Scael.El
1357*55008Scael.Pp
135851194SmarcIf the
1359*55008Scaelvalue of one of the changeable special control characters (see
1360*55008Scael.Sx "Special Characters" )
1361*55008Scaelis
1362*55008Scael.Dv {_POSIX_VDISABLE} ,
1363*55008Scaelthat function shall be disabled; that is, no input
1364*55008Scaeldata shall be recognized as the disabled special character.
1365*55008ScaelIf
1366*55008Scael.Dv ICANON
1367*55008Scaelis
1368*55008Scaelnot set, the value of
1369*55008Scael.Dv {_POSIX_VDISABLE}
1370*55008Scaelhas no special meaning for the
1371*55008Scael.Dv VMIN
1372*55008Scaeland
1373*55008Scael.Dv VTIME
1374*55008Scaelentries of the
1375*55008Scael.Fa c_cc
1376*55008Scaelarray.
1377*55008Scael.Pp
1378*55008ScaelThe initial values of the flags and control characters
137951194Smarcafter open() is set according to
1380*55008Scaelthe values in the header
1381*55008Scael.Aq Pa sys/ttydefaults.h .
1382