xref: /csrg-svn/share/man/man4/termios.4 (revision 55202)
155008Scael.\" Copyright (c) 1991, 1992 The Regents of the University of California.
251195Sbostic.\" All rights reserved.
351195Sbostic.\"
451195Sbostic.\" %sccs.include.redist.roff%
551195Sbostic.\"
6*55202Scael.\"	@(#)termios.4	5.3 (Berkeley) 07/14/92
751195Sbostic.\"
855008Scael.Dd
955008Scael.Dt TERMIOS 4
1055008Scael.Os BSD 4
1155008Scael.Sh NAME
1255008Scael.Nm termios
1355008Scael.Nd general terminal interface
1455008Scael.Sh SYNOPSIS
1555008Scael.Fd #include <termios.h>
1655008Scael.Sh DESCRIPTION
1751194SmarcThis describes a general terminal line discipline that is
1851194Smarcsupported on tty asynchronous communication ports.
1955008Scael.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
2255008Scaelof a connection is indicated by the assertion of the hardware
2355008Scael.Dv CARRIER line.
2451194SmarcIf the termios structure associated with the terminal file has the
2555008Scael.Dv CLOCAL
2655008Scaelflag set in the cflag, or if the
2755008Scael.Dv O_NONBLOCK
2855008Scaelflag is set
2955008Scaelin the
3055008Scael.Xr open 2
3155008Scaelcall, 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
3555008Scaelas
3655008Scael.Xr getty 2
3755008Scaelor
3855008Scael.Xr rlogind 2 ,
3955008Scaeland become
4051194Smarcan application's standard input, output, and error files.
4155008Scael.Ss Job Control in a Nutshell
4251194SmarcEvery process is associated with a particular process group and session.
4355008ScaelThe grouping is hierarchical: every member of a particular process group is a
4451194Smarcmember of the same session.  This structuring is used in managing groups
4555008Scaelof related processes for purposes of
4655008Scael.\" .Gw "job control" ;
4755008Scael.Em "job control" ;
4855008Scaelthat is, the
4955008Scaelability 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
5555008Scaelterminal.  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
6155008Scaelterminal.
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
6655008Scaelis 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
7055008Scaela 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
8255008Scaeltype a key (ususally
8355008Scael.Ql \&^Z )
8455008Scaelwhich generates the terminal stop signal
8555008Scael.Pq Dv SIGTSTP
8655008Scaeland 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.
9155008Scael.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.
10055008Scael.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
10555008Scaelthe session leader by issuing the
10655008Scael.Dv TIOCSCTTY
10755008Scaelioctl.  A controlling terminal
10851194Smarcis never acquired by mereley opening a terminal device file.
10951194SmarcWhen a controlling terminal becomes
11055008Scaelassociated with a session, its foreground process group is set to
11151194Smarcthe process group of the session leader.
11255008Scael.Pp
11355008ScaelThe controlling terminal is inherited by a child process during a
11455008Scael.Xr fork 2
11551194Smarcfunction call.  A process relinquishes its controlling terminal when it
11655008Scaelcreates a new session with the
11755008Scael.Xd setsid 2
11855008Scaelfunction; other processes
11951194Smarcremaining in the old session that had this terminal as their controlling
12055008Scaelterminal 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.
12555008Scael.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.
13155008Scael.Ss Terminal Access Control
13251194SmarcIf a process is in the foreground process group of its controlling
13355008Scaelterminal, read operations are allowed.
13451194SmarcAny attempts by a process
13555008Scaelin a background process group to read from its controlling terminal
13655008Scaelcauses a
13755008Scael.Dv SIGTTIN
13855008Scaelsignal to be sent to
13955008Scaelthe process's group
14055008Scaelunless one of the
14151194Smarcfollowing special cases apply:  If the reading process is ignoring or
14255008Scaelblocking the
14355008Scael.Dv SIGTTIN signal, or if the process group of the reading
14455008Scaelprocess is orphaned, the
14555008Scael.Xr read 2
14655008Scaelreturns -1 with
14755008Scael.Va errno set to
14855008Scael.Er Dv EIO
14955008Scaeland no
15055008Scaelsignal is sent.  The default action of the
15155008Scael.Dv SIGTTIN
15255008Scaelsignal is to stop the
15351194Smarcprocess to which it is sent.
15455008Scael.Pp
15551194SmarcIf a process is in the foreground process group of its controlling
15655008Scaelterminal, write operations are allowed.
15751194SmarcAttempts by a process in a background process group to write to its
15855008Scaelcontrolling terminal will cause the process group to be sent a
15955008Scael.Dv SIGTTOU
16055008Scaelsignal unless one of the following special cases apply:  If
16155008Scael.Dv TOSTOP
16255008Scaelis not
16355008Scaelset, or if
16455008Scael.Dv TOSTOP
16555008Scaelis set and the process is ignoring or blocking the
16655008Scael.Dv SIGTTOU
16755008Scaelsignal, the process is allowed to write to the terminal and the
16855008Scael.Dv SIGTTOU
16955008Scaelsignal is not sent.  If
17055008Scael.Dv TOSTOP
17155008Scaelis set, and the process group of
17251194Smarcthe writing process is orphaned, and the writing process is not ignoring
17355008Scaelor blocking
17455008Scael.Dv SIGTTOU ,
17555008Scaelthe
17655008Scael.Xr write
17755008Scaelreturns -1 with
17855008Scaelerrno set to
17955008Scael.Er Dv EIO
18055008Scaeland no signal is sent.
18155008Scael.Pp
18251194SmarcCertain calls that set terminal parameters are treated in the same
18355008Scaelfashion as write, except that
18455008Scael.Dv TOSTOP
18555008Scaelis ignored; that is, the effect is
18655008Scaelidentical to that of terminal writes when
18755008Scael.Dv TOSTOP
18855008Scaelis set.
18955008Scael.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
19455008Scaelprocess.  The system imposes a limit,
19555008Scael.Pf \&{ Dv MAX_INPUT Ns \&} ,
19655008Scaelon the number of
19751194Smarcbytes that may be stored in the input queue.  The behavior of the system
19855008Scaelwhen this limit is exceeded depends on the setting of the
19955008Scael.Dv IMAXBEL
20055008Scaelflag in the termios
20155008Scael.Fa c_iflag .
20255008ScaelIf this flag is set, the terminal
20355008Scaelis a sent an
20455008Scael.Tn ASCII
20555008Scael.Dv BEL
20655008Scaelcharacter each time a character is recieved
20751194Smarcwhile the input queue is full.  Otherwise, the input queue is flushed
20851194Smarcupon receiving the character.
20955008Scael.Pp
21051194SmarcTwo general kinds of input processing are available, determined by
21151194Smarcwhether the terminal device file is in canonical mode or noncanonical
21251194Smarcmode. Additionally,
21355008Scaelinput characters are processed according to the
21455008Scael.Fa c_iflag
21555008Scaeland
21655008Scael.Fa c_lflag
21755008Scaelfields.  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.
22155008Scael.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.
22555008Scael.Pp
22655008ScaelAnother dependency is whether the
22755008Scael.Dv O_NONBLOCK
22855008Scaelflag is set by
22955008Scael.Xr open()
23055008Scaelor
23155008Scael.Xr fcntl() .
23255008ScaelIf the
23355008Scael.Dv O_NONBLOCK
23455008Scaelflag is clear, then the read request is
23551194Smarcblocked until data is available or a signal has been received.  If the
23655008Scael.Dv O_NONBLOCK
23755008Scaelflag is set, then the read request is completed, without
23851194Smarcblocking, in one of three ways:
23955008Scael.Bl -enum -offset indent
24055008Scael.It
24155008ScaelIf there is enough data available to satisfy the entire request,
24255008Scaeland the read completes successfully the number of
24355008Scaelbytes read is returned.
24455008Scael.It
24555008ScaelIf there is not enough data available to satisfy the entire
24655008Scaelrequest, and the read completes successfully, having read as
24755008Scaelmuch data as possible, the number of bytes read is returned.
24855008Scael.It
24955008ScaelIf there is no data available, the read returns -1, with
25055008Scaelerrno set to
25155008Scael.Br EAGAIN .
25255008Scael.El
25355008Scael.Pp
25451194SmarcWhen data is available depends on whether the input processing mode is
25555008Scaelcanonical or noncanonical.
25655008Scael.Ss Canonical Mode Input Processing
25751194SmarcIn canonical mode input processing, terminal input is processed in units
25855008Scaelof lines.  A line is delimited by a newline
25955008Scael.Ql \&\en
26055008Scaelcharacter, an end-of-file
26155008Scael.Pq Dv EOF
26255008Scaelcharacter, or an end-of-line
26355008Scael.Pq Dv EOL
26455008Scaelcharacter.  See the
26555008Scael.Sx "Special Characters"
26655008Scaelsection for
26755008Scaelmore information on
26855008Scael.Dv EOF
26955008Scaeland
27055008Scael.Dv EOL .
27155008ScaelThis 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,
27455008Scaelat 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.
27755008Scael.Pp
27855008Scael.Pf \&{ Dv MAX_CANON Ns \&}
27955008Scaelis a limit on the
28055008Scaelnumber of bytes in a line.
28151194SmarcThe behavior of the system when this limit is
28255008Scaelexceeded is the same as when the input queue limit
28355008Scael.Pf \&{ Dv MAX_INPUT Ns \&} ,
28455008Scaelis exceeded.
28555008Scael.Pp
28651194SmarcErase and kill processing occur when either of two special characters,
28755008Scaelthe
28855008Scael.Dv ERASE
28955008Scaeland
29055008Scael.Dv KILL
29155008Scaelcharacters (see the
29255008Scael.Sx "Special Characters section" ) ,
29355008Scaelis received.
29451194SmarcThis processing affects data in the input queue that has not yet been
29555008Scaeldelimited by a newline
29655008Scael.Dv NL,
29755008Scael.Dv EOF ,
29855008Scaelor
29955008Scael.Dv EOL
30055008Scaelcharacter.  This un-delimited
30155008Scaeldata makes up the current line.  The
30255008Scael.Dv ERASE
30355008Scaelcharacter deletes the last
30455008Scaelcharacter in the current line, if there is any.  The
30555008Scael.Dv KILL
30655008Scaelcharacter
30755008Scaeldeletes all data in the current line, if there is any.  The
30855008Scael.Dv ERASE
30955008Scaeland
31055008Scael.Dv KILL
31155008Scaelcharacters have no effect if there is no data in the current line.
31255008ScaelThe
31355008Scael.Dv ERASE
31455008Scaeland
31555008Scael.Dv KILL
31655008Scaelcharacters themselves are not placed in the input
31751194Smarcqueue.
31855008Scael.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
32155008Scael.Dv MIN
32255008Scaeland
32355008Scael.Dv TIME
32455008Scaelmembers of the
32555008Scael.Fa c_cc
32655008Scaelarray are used to determine how to
32751194Smarcprocess the bytes received.
32855008Scael.Pp
32955008Scael.Dv MIN
33055008Scaelrepresents the minimum number of bytes that should be received when
33155008Scaelthe
33255008Scael.Xr read
33355008Scaelfunction successfully returns.
33455008Scael.Dv TIME
33555008Scaelis a timer of 0.1 second
33651194Smarcgranularity that is used to time out bursty and short term data
33755008Scaeltransmissions.  If
33855008Scael.Dv MIN
33955008Scaelis greater than
34055008Scael.Dv \&{ Dv MAX_INPUT Ns \&} ,
34155008Scaelthe response to the
34255008Scaelrequest is undefined.  The four possible values for
34355008Scael.Dv MIN
34455008Scaeland
34555008Scael.Dv TIME
34655008Scaeland
34751194Smarctheir interactions are described below.
34855008Scael.Ss "Case A: MIN > 0, TIME > 0"
34955008ScaelIn this case
35055008Scael.Dv TIME
35155008Scaelserves as an inter-byte timer and is activated after
35251194Smarcthe first byte is received.  Since it is an inter-byte timer, it is reset
35355008Scaelafter a byte is received.  The interaction between
35455008Scael.Dv MIN
35555008Scaeland
35655008Scael.Dv TIME
35755008Scaelis as
35851194Smarcfollows:  as soon as one byte is received, the inter-byte timer is
35955008Scaelstarted.  If
36055008Scael.Dv MIN
36155008Scaelbytes are received before the inter-byte timer expires
36251194Smarc(remember that the timer is reset upon receipt of each byte), the read is
36355008Scaelsatisfied.  If the timer expires before
36455008Scael.Dv MIN
36555008Scaelbytes are received, the
36651194Smarccharacters received to that point are returned to the user.  Note that if
36755008Scael.Dv TIME
36855008Scaelexpires at least one byte is returned because the timer would
36955008Scaelnot have been enabled unless a byte was received.  In this case
37055008Scael.Pf \&( Dv MIN
37155008Scael> 0,
37255008Scael.Dv TIME
37355008Scael> 0) the read blocks until the
37455008Scael.Dv MIN
37555008Scaeland
37655008Scael.Dv TIME
37755008Scaelmechanisms are
37851194Smarcactivated by the receipt of the first byte, or a signal is received.  If
37955008Scaeldata is in the buffer at the time of the read(), the result is as
38051194Smarcif data had been received immediately after the read().
38155008Scael.Ss "Case B: MIN > 0, TIME = 0"
38255008ScaelIn this case, since the value of
38355008Scael.Dv TIME
38455008Scaelis zero, the timer plays no role
38555008Scaeland only
38655008Scael.Dv MIN
38755008Scaelis significant.  A pending read is not satisfied until
38855008Scael.Dv MIN
38955008Scaelbytes are received (i.e., the pending read blocks until
39055008Scael.Dv MIN
39155008Scaelbytes
39251194Smarcare received), or a signal is received.  A program that uses this case to
39355008Scaelread record-based terminal
39455008Scael.Dv I/O
39555008Scaelmay block indefinitely in the read
39651194Smarcoperation.
39755008Scael.Ss "Case C: MIN = 0, TIME > 0"
39855008ScaelIn this case, since
39955008Scael.Dv MIN
40055008Scael= 0,
40155008Scael.Dv TIME
40255008Scaelno longer represents an inter-byte
40351194Smarctimer.  It now serves as a read timer that is activated as soon as the
40455008Scaelread 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
40655008Scaelthe 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.
40855008ScaelIn this case the read will not block indefinitely waiting for a byte; if
40955008Scaelno byte is received within
41055008Scael.Dv TIME Ns *0.1
41155008Scaelseconds after the read is initiated,
41255008Scaelthe read returns a value of zero, having read no data.  If data is
41355008Scaelin the buffer at the time of the read, the timer is started as if
41455008Scaeldata had been received immediately after the read.
41555008Scael.Ss Case D: MIN = 0, TIME = 0
41651194SmarcThe minimum of either the number of bytes requested or the number of
41755008Scaelbytes currently available is returned without waiting for more
41855008Scaelbytes to be input.  If no characters are available, read returns a
41951194Smarcvalue of zero, having read no data.
42055008Scael.Ss Writing Data and Output Processing
42151194SmarcWhen a process writes one or more bytes to a terminal device file, they
42255008Scaelare processed according to the
42355008Scael.Fa c_oflag
42455008Scaelfield (see the
42555008Scael.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
43055008Scaelhave completed.
43155008Scael.\" See also .Sx "6.4.2" for the effects of
43255008Scael.\" .Dv O_NONBLOCK
43355008Scael.\" on write.
43455008Scael.Ss Special Characters
43551194SmarcCertain characters have special functions on input or output or both.
43651194SmarcThese functions are summarized as follows:
43755008Scael.Bl -tag -width indent
43855008Scael.It Dv INTR
43955008ScaelSpecial character on input and is recognized if the
44055008Scael.Dv ISIG
44155008Scaelflag (see the
44255008Scael.Sx "Local Modes"
44355008Scaelsection) is enabled.  Generates a
44455008Scael.Dv SIGINT
44555008Scaelsignal which is sent to all processes in the foreground
44655008Scaelprocess group for which the terminal is the controlling
44755008Scaelterminal.  If
44855008Scael.Dv ISIG
44955008Scaelis set, the
45055008Scael.Dv INTR
45155008Scaelcharacter is
45255008Scaeldiscarded when processed.
45355008Scael.It Dv QUIT
45455008ScaelSpecial character on input and is recognized if the
45555008Scael.Dv ISIG
45655008Scaelflag is enabled.  Generates a
45755008Scael.Dv SIGQUIT
45855008Scaelsignal which is
45955008Scaelsent to all processes in the foreground process group
46055008Scaelfor which the terminal is the controlling terminal.  If
46155008Scael.Dv ISIG
46255008Scaelis set, the
46355008Scael.Dv QUIT
46455008Scaelcharacter is discarded when
46555008Scaelprocessed.
46655008Scael.It Dv ERASE
46755008ScaelSpecial character on input and is recognized if the
46855008Scael.Dv ICANON
46955008Scaelflag is set.  Erases the last character in the
47055008Scaelcurrent line; see
47155008Scael.Sx "Canonical Mode Input Processing" .
47255008ScaelIt does not erase beyond
47355008Scaelthe start of a line, as delimited by an
47455008Scael.Dv NL ,
47555008Scael.Dv EOF ,
47655008Scaelor
47755008Scael.Dv EOL
47855008Scaelcharacter.  If
47955008Scael.Dv ICANON
48055008Scaelis set, the
48155008Scael.Dv ERASE
48255008Scaelcharacter is
48355008Scaeldiscarded when processed.
48455008Scael.It Dv KILL
48555008ScaelSpecial character on input and is recognized if the
48655008Scael.Dv ICANON
48755008Scaelflag is set.  Deletes the entire line, as
48855008Scaeldelimited by a
48955008Scael.Dv NL ,
49055008Scael.Dv EOF ,
49155008Scaelor
49255008Scael.Dv EOL
49355008Scaelcharacter.  If
49455008Scael.Dv ICANON
49555008Scaelis set, the
49655008Scael.Dv KILL
49755008Scaelcharacter is discarded when processed.
49855008Scael.It Dv EOF
49955008ScaelSpecial character on input and is recognized if the
50055008Scael.Dv ICANON
50155008Scaelflag is set.  When received, all the bytes
50255008Scaelwaiting to be read are immediately passed to the
50355008Scaelprocess, without waiting for a newline, and the
50455008Scael.Dv EOF
50555008Scaelis discarded.  Thus, if there are no bytes waiting (that
50655008Scaelis, the
50755008Scael.Dv EOF
50855008Scaeloccurred at the beginning of a line), a byte
50955008Scaelcount of zero is returned from the read(),
51055008Scaelrepresenting an end-of-file indication.  If
51155008Scael.Dv ICANON
51255008Scaelis
51355008Scaelset, the
51455008Scael.Dv EOF
51555008Scaelcharacter is discarded when processed.
51655008Scael.Dv NL
51755008ScaelSpecial character on input and is recognized if the
51855008Scael.Dv ICANON
51955008Scaelflag is set.  It is the line delimiter
52055008Scael.Ql \&\en .
52155008Scael.It Dv EOL
52255008ScaelSpecial character on input and is recognized if the
52355008Scael.Dv ICANON
52455008Scaelflag is set.  Is an additional line delimiter,
52555008Scaellike
52655008Scael.Dv NL .
52755008Scael.It Dv SUSP
52855008ScaelIf the
52955008Scael.Dv ISIG
53055008Scaelflag is enabled, receipt of the
53155008Scael.Dv SUSP
53255008Scaelcharacter causes a
53355008Scael.Dv SIGTSTP
53455008Scaelsignal to be sent to all processes in the
53555008Scaelforeground process group for which the terminal is the
53655008Scaelcontrolling terminal, and the
53755008Scael.Dv SUSP
53855008Scaelcharacter is
53955008Scaeldiscarded when processed.
54055008Scael.It Dv STOP
54155008ScaelSpecial character on both input and output and is
54255008Scaelrecognized if the
54355008Scael.Dv IXON
54455008Scael(output control) or
54555008Scael.Dv IXOFF
54655008Scael(input
54755008Scaelcontrol) flag is set.  Can be used to temporarily
54855008Scaelsuspend output.  It is useful with fast terminals to
54955008Scaelprevent output from disappearing before it can be read.
55055008ScaelIf
55155008Scael.Dv IXON
55255008Scaelis set, the
55355008Scael.Dv STOP
55455008Scaelcharacter is discarded when
55555008Scaelprocessed.
55655008Scael.It Dv START
55755008ScaelSpecial character on both input and output and is
55855008Scaelrecognized if the
55955008Scael.Dv IXON
56055008Scael(output control) or
56155008Scael.Dv IXOFF
56255008Scael(input
56355008Scaelcontrol) flag is set.  Can be used to resume output that
56455008Scaelhas been suspended by a
56555008Scael.Dv STOP
56655008Scaelcharacter.  If
56755008Scael.Dv IXON
56855008Scaelis set, the
56955008Scael.Dv START
57055008Scaelcharacter is discarded when processed.
57155008Scael.Dv CR
57255008ScaelSpecial character on input and is recognized if the
57355008Scael.Dv ICANON
57455008Scaelflag is set; it is the
57555008Scael.Ql \&\er ,
57655008Scaelas denoted in the
57755008Scael.Tn \&C
57855008ScaelStandard {2}.  When
57955008Scael.Dv ICANON
58055008Scaeland
58155008Scael.Dv ICRNL
58255008Scaelare set and
58355008Scael.Dv IGNCR
58455008Scaelis not set, this character is translated into a
58555008Scael.Dv NL ,
58655008Scaeland
58755008Scaelhas the same effect as a
58855008Scael.Dv NL
58955008Scaelcharacter.
59055008Scael.El
59155008Scael.Pp
59251194SmarcThe following special characters are extensions defined by this
59351194Smarcsystem and are not a part of 1003.1 termios.
59455008Scael.Bl -tag -width indent
595*55202Scael.It Dv EOL2
59655008ScaelSecondary
59755008Scael.Dv EOL
59855008Scaelcharacter.  Same function as
59955008Scael.Dv EOL.
60055008Scael.It Dv WERASE
60155008ScaelSpecial character on input and is recognized if the
60255008Scael.Dv ICANON
60355008Scaelflag is set.  Erases the last word in the current
60455008Scaelline according to one of two algorithms.  If the
60555008Scael.Dv ALTWERASE
60655008Scaelflag is not set, first any preceding whitespace is
60755008Scaelerased, and then the maximal sequence of non-whitespace
60855008Scaelcharacters.  If
60955008Scael.Dv ALTWERASE
61055008Scaelis set, first any preceding
61155008Scaelwhitespace is erased, and then the maximal sequence
61255008Scaelof alphabetic/underscores or non alphabetic/underscores.
61355008ScaelAs a special case in this second algorithm, the first previous
61455008Scaelnon-whitespace character is skippied in determining
61555008Scaelwhether the preceding word is a sequence of
61655008Scaelalphabetic/undercores.  This sounds confusing but turns
61755008Scaelout to be quite practical.
61855008Scael.It Dv REPRINT
61955008ScaelSpecial character on input and is recognized if the
62055008Scael.Dv ICANON
62155008Scaelflag is set.  Causes the current input edit line
62255008Scaelto be retyped.
62355008Scael.It Dv DSUSP
62455008ScaelHas similar actions to the
62555008Scael.Dv SUSP
62655008Scaelcharacter, except that
62755008Scaelthe
62855008Scael.Dv SIGTSTP
62955008Scaelsignal is delivered when one of the processes
63055008Scaelin the foreground process group issues a read() to the
63155008Scaelcontrolling terminal.
63255008Scael.It Dv LNEXT
63355008ScaelSpecial character on input and is recognized if the
63455008Scael.Dv IEXTEN
63555008Scaelflag is set.  Receipt of this character causes the next
63655008Scaelcharacter to be taken literally.
63755008Scael.It Dv DISCARD
63855008ScaelSpecial character on input and is recognized if the
63955008Scael.Dv IEXTEN
64055008Scaelflag is set.  Receipt of this character toggles the flushing
64155008Scaelof terminal output.
64255008Scael.It Dv STATUS
64355008ScaelSpecial character on input and is recognized if the
64455008Scael.Dv ICANON
64555008Scaelflag is set.  Receipt of this character causes a
64655008Scael.Dv SIGINFO
64755008Scaelsignal to be sent to the forground process group of the
64855008Scaelterminal.  Also, if the
64955008Scael.Dv NOKERNINFO
65055008Scaelflag is not set, it
65155008Scaelcauses the kernel to write a status message to the terminal
65255008Scaelthat displays the current load average, the name of the
65355008Scaelcommand in the foreground, its process ID, the symbolic
65455008Scaelwait channel, the number of user and system seconds used,
65555008Scaelthe percentage of cpu the process is getting, and the resident
65655008Scaelset size of the process.
65755008Scael.El
65855008Scael.Pp
65955008ScaelThe
66055008Scael.Dv NL
66155008Scaeland
66255008Scael.Dv CR
66355008Scaelcharacters cannot be changed.
66451194SmarcThe values for all the remaining characters can be set and are
66555008Scaeldescribed later in the document under
66655008ScaelSpecial Control Characters.
66755008Scael.Pp
66851194SmarcSpecial
66951194Smarccharacter functions associated with changeable special control characters
67055008Scaelcan be disabled individually by setting their value to
67155008Scael.Dv {_POSIX_VDISABLE};
67255008Scaelsee
67355008Scael.Sx "Special Control Characters" .
67455008Scael.Pp
67551194SmarcIf two or more special characters have the same value, the function
67651194Smarcperformed when that character is received is undefined.
67755008Scael.Ss Modem Disconnect
67851194SmarcIf a modem disconnect is detected by the terminal interface for a
67955008Scaelcontrolling terminal, and if
68055008Scael.Dv CLOCAL
68155008Scaelis not set in the
68255008Scael.Fa c_cflag
68355008Scaelfield for
68455008Scaelthe terminal, the
68555008Scael.Dv SIGHUP
68655008Scaelsignal is sent to the controlling
68751194Smarcprocess associated with the terminal.  Unless other arrangements have
68851194Smarcbeen made, this causes the controlling process to terminate.
68955008ScaelAny 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
69255008Scaeldisconnect.
69355008Scael.\" If the
69455008Scael.\" .Er EIO
69555008Scael.\" condition specified in 6.1.1.4 that applies
69655008Scael.\" when the implementation supports job control also exists, it is
69755008Scael.\" unspecified whether the
69855008Scael.\" .Dv EOF
69955008Scael.\" condition or the
70055008Scael.\" .Pf [ Dv EIO
70155008Scael.\" ] is returned.
70255008ScaelAny
70355008Scaelsubsequent write() to the terminal device returns -1, with
70455008Scael.Va errno
70555008Scaelset to
70655008Scael.Er EIO ,
70755008Scaeluntil the device is closed.
70855008Scael.Sh General Terminal Interface
70955008Scael.Pp
71055008Scael.Ss Closing a Terminal Device File
71155008ScaelThe last process to close a terminal device file causes any output
71255008Scaelto be sent to the device and any input to be discarded.  Then, if
71355008Scael.Dv HUPCL
71451194Smarcis set in the control modes, and the communications port supports a
71555008Scaeldisconnect function, the terminal device performs a disconnect.
71655008Scael.Ss Parameters That Can Be Set
71755008ScaelRoutines that need to control certain terminal
71855008Scael.Tn I/O
71955008Scaelcharacteristics
72051194Smarcdo so by using the termios structure as defined in the header
72155008Scael.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
72455008Scaelnamed:
72555008Scael.Fa c_iflag ,
72655008Scael.Fa c_oflag ,
72755008Scael.Fa c_cflag ,
72855008Scaeland
72955008Scael.Fa c_lflag .  The character array
73055008Scaelis named
73155008Scael.Fa c_cc ,
73255008Scaeland its maximum index is
73355008Scael.Dv NCCS .
73455008Scael.Ss Input Modes
73555008ScaelValues of the
73655008Scael.Fa c_iflag
73755008Scaelfield describe the basic
73851194Smarcterminal input control, and are composed of
73955008Scaelfollowing masks:
74055008Scael.Pp
74155008Scael.Bl -tag -width IMAXBEL -offset indent -compact
74255008Scael.It Dv IGNBRK
74355008Scael/* ignore BREAK condition */
74455008Scael.It Dv BRKINT
74555008Scael/* map BREAK to SIGINTR */
74655008Scael.It Dv IGNPAR
74755008Scael/* ignore (discard) parity errors */
74855008Scael.It Dv PARMRK
74955008Scael/* mark parity and framing errors */
75055008Scael.It Dv INPCK
75155008Scael/* enable checking of parity errors */
75255008Scael.It Dv ISTRIP
75355008Scael/* strip 8th bit off chars */
75455008Scael.It Dv INLCR
75555008Scael/* map NL into CR */
75655008Scael.It Dv IGNCR
75755008Scael/* ignore CR */
75855008Scael.It Dv ICRNL
75955008Scael/* map CR to NL (ala CRMOD) */
76055008Scael.It Dv IXON
76155008Scael/* enable output flow control */
76255008Scael.It Dv IXOFF
76355008Scael/* enable input flow control */
76455008Scael.It Dv IXANY
76555008Scael/* any char will restart after stop */
76655008Scael.It Dv IMAXBEL
76755008Scael/* ring bell on input queue full */
76855008Scael.El
76955008Scael.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.
77755008Scael.Pp
77855008ScaelIf
77955008Scael.Dv IGNBRK
78055008Scaelis 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
78255008Scael.Dv IGNBRK
78355008Scaelis not set and
78455008Scael.Dv BRKINT
78555008Scaelis set, the break condition flushes the
78651194Smarcinput and output queues and if the terminal is the controlling terminal
78755008Scaelof a foreground process group, the break condition generates a
78855008Scaelsingle
78955008Scael.Dv SIGINT
79055008Scaelsignal to that foreground process group.  If neither
79155008Scael.Dv IGNBRK
79255008Scaelnor
79355008Scael.Dv BRKINT
79455008Scaelis set, a break condition is read as a single
79555008Scael.Ql \&\e0 ,
79655008Scaelor if
79755008Scael.Dv PARMRK
79855008Scaelis set, as
79955008Scael.Ql \&\e377 ,
80055008Scael.Ql \&\e0 ,
80155008Scael.Ql \&\e0 .
80255008Scael.Pp
80355008ScaelIf
80455008Scael.Dv IGNPAR
80555008Scaelis set, a byte with a framing or parity error (other than
80651194Smarcbreak) is ignored.
80755008Scael.Pp
80855008ScaelIf
80955008Scael.Dv PARMRK
81055008Scaelis set, and
81155008Scael.Dv IGNPAR
81255008Scaelis not set, a byte with a framing or parity
81351194Smarcerror (other than break) is given to the application as the three-
81455008Scaelcharacter sequence
81555008Scael.Ql \&\e377 ,
81655008Scael.Ql \&\e0 ,
81755008ScaelX, where
81855008Scael.Ql \&\e377 ,
81955008Scael.Ql \&\e0
82055008Scaelis a two-character
82151194Smarcflag preceding each sequence and X is the data of the character received
82255008Scaelin error.  To avoid ambiguity in this case, if
82355008Scael.Dv ISTRIP
82455008Scaelis not set, a valid
82555008Scaelcharacter of
82655008Scael.Ql \&\e377
82755008Scaelis given to the application as
82855008Scael.Ql \&\e377 ,
82955008Scael.Ql \&\e377 .
83055008ScaelIf
83155008Scaelneither
83255008Scael.Dv PARMRK
83355008Scaelnor
83455008Scael.Dv IGNPAR
83555008Scaelis set, a framing or parity error (other than
83655008Scaelbreak) is given to the application as a single character
83755008Scael.Ql \&\e0 .
83855008Scael.Pp
83955008ScaelIf
84055008Scael.Dv INPCK
84155008Scaelis set, input parity checking is enabled.  If
84255008Scael.Dv INPCK
84355008Scaelis 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
84755008Scaelor disabled (see
84855008Scael.Sx "Control Modes" ) .
84955008ScaelIf parity detection is enabled but input
85051194Smarcparity checking is disabled, the hardware to which the terminal is
85155008Scaelconnected recognizes the parity bit, but the terminal special file
85255008Scaeldoes not check whether this bit is set correctly or not.
85355008Scael.Pp
85455008ScaelIf
85555008Scael.Dv ISTRIP
85655008Scaelis set, valid input bytes are first stripped to seven bits,
85751194Smarcotherwise all eight bits are processed.
85855008Scael.Pp
85955008ScaelIf
86055008Scael.Dv INLCR
86155008Scaelis set, a received
86255008Scael.Dv NL character is translated into a
86355008Scael.Dv CR
86455008Scaelcharacter.  If
86555008Scael.Dv IGNCR
86655008Scaelis set, a received
86755008Scael.Dv CR
86855008Scaelcharacter is ignored (not
86955008Scaelread).  If
87055008Scael.Dv IGNCR
87155008Scaelis not set and
87255008Scael.Dv ICRNL
87355008Scaelis set, a received
87455008Scael.Dv CR
87555008Scaelcharacter is
87655008Scaeltranslated into a
87755008Scael.Dv NL
87855008Scaelcharacter.
87955008Scael.Pp
88055008ScaelIf
88155008Scael.Dv IXON
88255008Scaelis set, start/stop output control is enabled.  A received
88355008Scael.Dv STOP
88455008Scaelcharacter suspends output and a received
88555008Scael.Dv START
88655008Scaelcharacter
88755008Scaelrestarts output. If
88855008Scael.Dv IXANY
88955008Scaelis also set, then any character may
89055008Scaelrestart output. When
89155008Scael.Dv IXON
89255008Scaelis set,
89355008Scael.Dv START
89455008Scaeland
89555008Scael.Dv STOP
89655008Scaelcharacters are not
89755008Scaelread, but merely perform flow control functions.  When
89855008Scael.Dv IXON
89955008Scaelis not set,
90055008Scaelthe
90155008Scael.Dv START
90255008Scaeland
90355008Scael.Dv STOP
90455008Scaelcharacters are read.
90555008Scael.Pp
90655008ScaelIf
90755008Scael.Dv IXOFF
90855008Scaelis set, start/stop input control is enabled.  The system shall
90955008Scaeltransmit one or more
91055008Scael.Dv STOP
91155008Scaelcharacters, 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
91455008Scael.Sx "Input Processing and Reading Data" ,
91555008Scaeland shall transmit one or more
91655008Scael.Dv START
91755008Scaelcharacters, which are
91851194Smarcintended to cause the terminal device to resume transmitting data, as
91951194Smarcsoon as the device can continue transmitting data without risk of
92055008Scaeloverflowing the input queue.  The precise conditions under which
92155008Scael.Dv STOP
92255008Scaeland
92355008ScaelSTART
92455008Scaelcharacters are transmitted are implementation defined.
92555008Scael.Pp
92655008ScaelIf
92755008Scael.Dv IMAXBEL
92855008Scaelis set and the input queue is full, subsequent input
92955008Scaelshall causes an
93055008Scael.Tn ASCII
93155008Scael.Dv BEL
93255008Scaelcharacter to be transmitted to the
93351194Smarcthe output queue.
93455008Scael.Pp
93551194SmarcThe initial input control value after open() is implementation defined.
93655008Scael.Ss Output Modes
93755008ScaelValues of the
93855008Scael.Fa c_oflag
93955008Scaelfield describe the basic terminal output control,
94051194Smarcand are composed of the following masks:
94155008Scael.Pp
94255008Scael.Bl -tag -width OXTABS -offset indent -compact
94355008Scael.It Dv OPOST
94455008Scael/* enable following output processing */
94555008Scael.It Dv ONLCR
94655008Scael/* map NL to CR-NL (ala
94755008Scael.Dv CRMOD)
94855008Scael*/
94955008Scael.It Dv OXTABS
95055008Scael/* expand tabs to spaces */
95155008Scael.It Dv ONOEOT
95255008Scael/* discard
95355008Scael.Dv EOT Ns 's
95455008Scael.Ql \&^D
95555008Scaelon output) */
95655008Scael.El
95755008Scael.Pp
95855008ScaelIf
95955008Scael.Dv OPOST
96055008Scaelis set, the remaining flag masks are interpreted as follows;
96151194Smarcotherwise characters are transmitted without change.
96255008Scael.Pp
96355008ScaelIf
96455008Scael.Dv ONLCR
96555008Scaelis set, newlines are translated to carriage return, linefeeds.
96655008Scael.Pp
96755008ScaelIf
96855008Scael.Dv OXTABS
96955008Scaelis set, tabs are expanded to the appropiate number of
97051194Smarcspaces (assuming 8 column tab stops).
97155008Scael.Pp
97255008ScaelIf
97355008Scael.Dv ONOEOT
97455008Scaelis set,
97555008Scael.Tn ASCII
97655008Scael.Dv EOT NS 's
97755008Scaelare discarded on output.
97855008Scael.Ss Control Modes
97955008ScaelValues of the
98055008Scael.Fa c_cflag
98155008Scaelfield describe the basic
98255008Scaelterminal hardware control, and are composed of the
98351194Smarcthe following masks.
98451194SmarcNot all values
98551194Smarcspecified are supported by all hardware.
98655008Scael.Pp
987*55202Scael.Bl -tag -width CRTSXIFLOW -offset indent -compact
98855008Scael.It Dv CSIZE
98955008Scael/* character size mask */
99055008Scael.It Dv CS5
99155008Scael/* 5 bits (pseudo) */
99255008Scael.It Dv CS6
99355008Scael/* 6 bits */
99455008Scael.It Dv CS7
99555008Scael/* 7 bits */
99655008Scael.It Dv CS8
99755008Scael/* 8 bits */
99855008Scael.It Dv CSTOPB
99955008Scael/* send 2 stop bits */
100055008Scael.It Dv CREAD
100155008Scael/* enable receiver */
100255008Scael.It Dv PARENB
100355008Scael/* parity enable */
100455008Scael.It Dv PARODD
100555008Scael/* odd parity, else even */
100655008Scael.It Dv HUPCL
100755008Scael/* hang up on last close */
100855008Scael.It Dv CLOCAL
100955008Scael/* ignore modem status lines */
101055008Scael.It Dv CCTS_OFLOW
101155008Scael/*
101255008Scael.Dv CTS
101355008Scaelflow control of output */
101455008Scael.It Dv CRTSCTS
101555008Scael/* same as
101655008Scael.Dv CCTS_OFLOW
101755008Scael*/
101855008Scael.It Dv CRTS_IFLOW
101955008Scael/* RTS flow control of input */
102055008Scael.It Dv MDMBUF
102155008Scael/* flow control output via Carrier */
102255008Scael.El
102355008Scael.Pp
102455008ScaelThe
102555008Scael.Dv CSIZE
102655008Scaelbits specify the byte size in bits for both transmission and
102755008Scaelreception.  The
102855008Scael.Fa c_cflag
102955008Scaelis masked with
103055008Scael.Dv CSIZE
103155008Scaeland compared with the
103255008Scaelvalues
103355008Scael.Dv CS5 ,
103455008Scael.Dv CS6 ,
103555008Scael.Dv CS7 ,
103655008Scaelor
103755008Scael.Dv CS8 .
103855008ScaelThis size does not include the parity bit, if any.  If
103955008Scael.Dv CSTOPB
104051194Smarcis set, two stop bits are used, otherwise one stop bit.  For example, at
104151194Smarc110 baud, two stop bits are normally used.
104255008Scael.Pp
104355008ScaelIf
104455008Scael.Dv CREAD
104555008Scaelis set, the receiver is enabled.  Otherwise, no characters shall
104651194Smarcbe received.  Not all hardware supports this bit.  In fact, this flag
104755008Scaelis pretty silly and if it were not part of the
104855008Scael.Nm termios
104955008Scaelspecification
105051194Smarcit would be ommitted.
105155008Scael.Pp
105255008ScaelIf
105355008Scael.Dv PARENB
105455008Scaelis set, parity generation and detection is enabled and a parity
105555008Scaelbit is added to each character.  If parity is enabled,
105655008Scael.Dv PARODD
105755008Scaelspecifies
105851194Smarcodd parity if set, otherwise even parity is used.
105955008Scael.Pp
106055008ScaelIf
106155008Scael.Dv HUPCL
106255008Scaelis 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.
106555008Scael.Pp
106655008ScaelIf
106755008Scael.Dv CLOCAL
106855008Scaelis set, a connection does not depend on the state of the modem
106955008Scaelstatus lines.  If
107055008Scael.Dv CLOCAL
107155008Scaelis clear, the modem status lines shall be
107251194Smarcmonitored.
107355008Scael.Pp
107451194SmarcUnder normal circumstances, a call to the open() function shall wait for
107555008Scaelthe modem connection to complete.  However, if the
107655008Scael.Dv O_NONBLOCK
107755008Scaelflag is set
107855008Scaelor if
107955008Scael.Dv CLOCAL
108055008Scaelhas been set, the open() function shall return
108151194Smarcimmediately without waiting for the connection.
108255008Scael.Pp
108355008ScaelThe
108455008Scael.Dv CCTS_OFLOW
108555008Scael.Pf ( Dv CRTSCTS )
108655008Scaelflag is currently unused.
108755008Scael.Pp
108855008ScaelIf
108955008Scael.Dv MDMBUF
109055008Scaelis set then output flow control is controlled by the state
109151194Smarcof Carrier Detect.
109255008Scael.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.
109955008Scael.Ss Local Modes
110051194SmarcValues of the c_lflag field describe the control of
110151194Smarcvarious functions, and are composed of the following
110255008Scaelmasks.
110355008Scael.Pp
110455008Scael.Bl -tag -width NOKERNINFO -offset indent -compact
110555008Scael.It Dv ECHOKE
110655008Scael/* visual erase for line kill */
110755008Scael.It Dv ECHOE
110855008Scael/* visually erase chars */
110955008Scael.It Dv ECHO
111055008Scael/* enable echoing */
111155008Scael.It Dv ECHONL
111255008Scael/* echo
111355008Scael.Dv NL
111455008Scaeleven if
111555008Scael.Dv ECHO
111655008Scaelis off */
111755008Scael.It Dv ECHOPRT
111855008Scael/* visual erase mode for hardcopy */
111955008Scael.It Dv ECHOCTL
112055008Scael/* echo control chars as ^(Char) */
112155008Scael.It Dv ISIG
112255008Scael/* enable signals
112355008Scael.Dv INTR ,
112455008Scael.Dv QUIT ,
112555008Scael.Dv [D]SUSP
112655008Scael*/
112755008Scael.It Dv ICANON
112855008Scael/* canonicalize input lines */
112955008Scael.It Dv ALTWERASE
113055008Scael/* use alternate
113155008Scael.Dv WERASE
113255008Scaelalgorithm */
113355008Scael.It Dv IEXTEN
113455008Scael/* enable
113555008Scael.Dv DISCARD
113655008Scaeland
113755008Scael.Dv LNEXT
113855008Scael*/
113955008Scael.It Dv EXTPROC
114055008Scael/* external processing */
114155008Scael.It Dv TOSTOP
114255008Scael/* stop background jobs from output */
114355008Scael.It Dv FLUSHO
114455008Scael/* output being flushed (state) */
114555008Scael.It Dv NOKERNINFO
114655008Scael/* no kernel output from
114755008Scael.Dv VSTATUS
114855008Scael*/
114955008Scael.It Dv PENDIN
115055008Scael/* XXX retype pending input (state) */
115155008Scael.It Dv NOFLSH
115255008Scael/* don't flush after interrupt */
115355008Scael.El
115455008Scael.Pp
115555008ScaelIf
115655008Scael.Dv ECHO
115755008Scaelis set, input characters are echoed back to the terminal.  If
115855008Scael.Dv ECHO
115955008Scaelis not set, input characters are not echoed.
116055008Scael.Pp
116155008ScaelIf
116255008Scael.Dv ECHOE
116355008Scaeland
116455008Scael.Dv ICANON
116555008Scaelare set, the
116655008Scael.Dv ERASE
116755008Scaelcharacter 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.
117155008Scael.Pp
117255008ScaelIf
117355008Scael.Dv ECHOK
117455008Scaeland
117555008Scael.Dv ICANON
117655008Scaelare set, the
117755008Scael.Dv KILL
117855008Scaelcharacter shall
117951194Smarccause the current line to be discarded and the system shall
118055008Scaelecho the
118155008Scael.Ql \&\en
118255008Scaelcharacter after the
118355008Scael.Dv KILL
118455008Scaelcharacter.
118555008Scael.Pp
118655008ScaelIf
118755008Scael.Dv ECHOKE
118855008Scaeland
118955008Scael.Dv ICANON
119055008Scaelare set, the
119155008Scael.Dv KILL
119255008Scaelcharacter shall cause
119351194Smarcthe current line to be discarded and the system shall cause
119451194Smarcthe terminal
119551194Smarcto erase the line from the display.
119655008Scael.Pp
119755008ScaelIf
119855008Scael.Dv ECHOPRT
119955008Scaeland
120055008Scael.Dv ICANON
120155008Scaelare set, the system shall assume
120251194Smarcthat the display is a printing device and shall print a
120355008Scaelbackslash and the erased characters when processing
120455008Scael.Dv ERASE
120551194Smarccharacters, followed by a forward slash.
120655008Scael.Pp
120755008ScaelIf
120855008Scael.Dv ECHOCTL
120955008Scaelis set, the system shall echo control characters
121051194Smarcin a visible fashion using a carrot followed by the control character.
121155008Scael.Pp
121255008ScaelIf
121355008Scael.Dv ALTWERASE
121455008Scaelis set, the system will use an alternative algorithm
121555008Scaelfor determining what constitutes a word when processing
121655008Scael.Dv WERASE
121755008Scaelcharacters (see
121855008Scael.Dv WERASE ) .
121955008Scael.Pp
122055008ScaelIf
122155008Scael.Dv ECHONL
122255008Scaeland
122355008Scael.Dv ICANON
122455008Scaelare set, the
122555008Scael.Ql \&\en
122655008Scaelcharacter shall be echoed even if
122755008Scael.Dv ECHO
122855008Scaelis not set.
122955008Scael.Pp
123055008ScaelIf
123155008Scael.Dv ICANON
123255008Scaelis set, canonical processing is enabled.  This enables the
123351194Smarcerase and kill edit functions, and the assembly of input characters into
123455008Scaellines delimited by
123555008Scael.Dv NL,
123655008Scael.Dv EOF ,
123755008Scaeland
123855008Scael.Dv EOL,
123955008Scaelas described in
124055008Scael.Sx "Canonical Mode Input Processing" .
124155008Scael.Pp
124255008ScaelIf
124355008Scael.Dv ICANON
124455008Scaelis not set, read requests are satisfied directly from the input
124555008Scaelqueue.  A read shall not be satisfied until at least
124655008Scael.Dv MIN
124755008Scaelbytes have been
124855008Scaelreceived or the timeout value
124955008Scael.Dv TIME
125055008Scaelexpired between bytes.  The time value
125155008Scaelrepresents tenths of seconds.  See
125255008Scael.Sx "Noncanonical Mode Input Processing"
125351194Smarcfor more details.
125455008Scael.Pp
125555008ScaelIf
125655008Scael.Dv ISIG
125755008Scaelis set, each input character is checked against the special
125855008Scaelcontrol characters
125955008Scael.Dv INTR ,
126055008Scael.Dv QUIT ,
126155008Scaeland
126255008Scael.Dv SUSP
126355008Scael(job control only).  If an input
126451194Smarccharacter matches one of these control characters, the function
126555008Scaelassociated with that character is performed.  If
126655008Scael.Dv ISIG
126755008Scaelis not set, no
126851194Smarcchecking is done.  Thus these special input functions are possible only
126955008Scaelif
127055008Scael.Dv ISIG
127155008Scaelis set.
127255008Scael.Pp
127355008ScaelIf
127455008Scael.Dv IEXTEN
127555008Scaelis set, implementation-defined functions shall be recognized
127655008Scaelfrom the input data.  It is implementation defined how
127755008Scael.Dv IEXTEN
127855008Scaelbeing set
127955008Scaelinteracts with
128055008Scael.Dv ICANON ,
128155008Scael.Dv ISIG ,
128255008Scael.Dv IXON ,
128355008Scaelor
128455008Scael.Dv IXOFF .
128555008ScaelIf
128655008Scael.Dv IEXTEN
128755008Scaelis not set, then
128851194Smarcimplementation-defined functions shall not be recognized, and the
128951194Smarccorresponding input characters shall be processed as described for
129055008Scael.Dv ICANON ,
129155008Scael.Dv ISIG ,
129255008Scael.Dv IXON ,
129355008Scaeland
129455008Scael.Dv IXOFF .
129555008Scael.Pp
129655008ScaelIf
129755008Scael.Dv NOFLSH
129855008Scaelis set, the normal flush of the input and output queues
129955008Scaelassociated with the
130055008Scael.Dv INTR ,
130155008Scael.Dv QUIT ,
130255008Scaeland
130355008Scael.Dv SUSP
130455008Scaelcharacters
130551194Smarcshall not be done.
130655008Scael.Pp
130755008ScaelIf
130855008Scael.Dv TOSTOP
130955008Scaelis set, the signal
131055008Scael.Dv SIGTTOU
131155008Scaelis 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
131555008Scaelcurrent output stream.  Processes that are blocking or ignoring
131655008Scael.Dv SIGTTOU
131755008Scaelsignals are excepted and allowed to produce output and the
131855008Scael.Dv SIGTTOU
131955008Scaelsignal
132051194Smarcis not sent.
132155008Scael.Pp
132255008ScaelIf
132355008Scael.Dv NOKERNINFO
132455008Scaelis set, the kernel shall not produce a status message
132555008Scaelwhen processing
132655008Scael.Dv STATUS
132755008Scaelcharacters (see
132855008Scael.Dv STATUS ) .
132955008Scael.Ss Special Control Characters
133055008ScaelThe 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
133355008Scaelthe system defaults, consult the header file
133455008Scael.Aq Pa ttydefaults.h .
133555008Scael.Pp
133655008Scael.Bl -column "Index Name" "Special Character" -offset indent -compact
133755008Scael.It Em "Index Name	Special Character	Default Value"
133855008Scael.It Dv VEOF Ta EOF Ta \&^D
133955008Scael.It Dv VEOL Ta EOL Ta _POSIX_VDISABLE
134055008Scael.It Dv VEOL2 Ta EOL2 Ta _POSIX_VDISABLE
134155008Scael.It Dv VERASE Ta ERASE Ta \&^? Ql \&\e177
134255008Scael.It Dv VWERASE  Ta WERASE Ta \&^W
134355008Scael.It Dv VKILL Ta KILL Ta \&^U
134455008Scael.It Dv VREPRINT Ta REPRINT Ta \&^R
134555008Scael.It Dv VINTR Ta INTR Ta \&^C
134655008Scael.It Dv VQUIT Ta QUIT Ta \&^\e\e Ql \&\e34
134755008Scael.It Dv VSUSP Ta SUSP Ta \&^Z
134855008Scael.It Dv VDSUSP Ta DSUSP Ta \&^Y
134955008Scael.It Dv VSTART Ta START Ta \&^Q
135055008Scael.It Dv VSTOP Ta STOP Ta \&^S
135155008Scael.It Dv VLNEXT Ta LNEXT Ta \&^V
135255008Scael.It Dv VDISCARD Ta DISCARD Ta \&^O
135355008Scael.It Dv VMIN Ta --- Ta \&1
135455008Scael.It Dv VTIME Ta --- Ta \&0
135555008Scael.It Dv VSTATUS Ta STATUS Ta \&^T
135655008Scael.El
135755008Scael.Pp
135851194SmarcIf the
135955008Scaelvalue of one of the changeable special control characters (see
136055008Scael.Sx "Special Characters" )
136155008Scaelis
136255008Scael.Dv {_POSIX_VDISABLE} ,
136355008Scaelthat function shall be disabled; that is, no input
136455008Scaeldata shall be recognized as the disabled special character.
136555008ScaelIf
136655008Scael.Dv ICANON
136755008Scaelis
136855008Scaelnot set, the value of
136955008Scael.Dv {_POSIX_VDISABLE}
137055008Scaelhas no special meaning for the
137155008Scael.Dv VMIN
137255008Scaeland
137355008Scael.Dv VTIME
137455008Scaelentries of the
137555008Scael.Fa c_cc
137655008Scaelarray.
137755008Scael.Pp
137855008ScaelThe initial values of the flags and control characters
137951194Smarcafter open() is set according to
138055008Scaelthe values in the header
138155008Scael.Aq Pa sys/ttydefaults.h .
1382