xref: /csrg-svn/share/man/man4/termios.4 (revision 66967)
161599Sbostic.\" Copyright (c) 1991, 1992, 1993
261599Sbostic.\"	The Regents of the University of California.  All rights reserved.
351195Sbostic.\"
451195Sbostic.\" %sccs.include.redist.roff%
551195Sbostic.\"
6*66967Sbostic.\"	@(#)termios.4	8.4 (Berkeley) 04/19/94
751195Sbostic.\"
855008Scael.Dd
955008Scael.Dt TERMIOS 4
1055008Scael.Os BSD 4
1155008Scael.Sh NAME
1255008Scael.Nm termios
1357602Smarc.Nd general terminal line discipline
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
66*66967Sbosticis collectively referred 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
82*66967Sbostictype a key (usually
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,
9064994Smckusickand for placing stopped or background jobs into 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
10864994Smckusickis never acquired by merely 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
20366807Sbosticis sent an
20455008Scael.Tn ASCII
20555008Scael.Dv BEL
20664994Smckusickcharacter each time a character is received
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
25164994Smckusick.Er 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
43064994Smckusickhave been 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
59555202Scael.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
61464994Smckusicknon-whitespace character is skipped 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
64764994Smckusicksignal to be sent to the foreground 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.
68964994SmckusickAny subsequent call to the read() function returns 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
72964994Smckusick.Fa c_lflag .
73064994SmckusickThe character array is 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
81364994Smckusickerror (other than break) is given to the application as the
81464994Smckusickthree-character 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
86264994Smckusick.Dv NL
86364994Smckusickcharacter is translated into a
86455008Scael.Dv CR
86555008Scaelcharacter.  If
86655008Scael.Dv IGNCR
86755008Scaelis set, a received
86855008Scael.Dv CR
86955008Scaelcharacter is ignored (not
87055008Scaelread).  If
87155008Scael.Dv IGNCR
87255008Scaelis not set and
87355008Scael.Dv ICRNL
87455008Scaelis set, a received
87555008Scael.Dv CR
87655008Scaelcharacter is
87755008Scaeltranslated into a
87855008Scael.Dv NL
87955008Scaelcharacter.
88055008Scael.Pp
88155008ScaelIf
88255008Scael.Dv IXON
88355008Scaelis set, start/stop output control is enabled.  A received
88455008Scael.Dv STOP
88555008Scaelcharacter suspends output and a received
88655008Scael.Dv START
88755008Scaelcharacter
88855008Scaelrestarts output. If
88955008Scael.Dv IXANY
89055008Scaelis also set, then any character may
89155008Scaelrestart output. When
89255008Scael.Dv IXON
89355008Scaelis set,
89455008Scael.Dv START
89555008Scaeland
89655008Scael.Dv STOP
89755008Scaelcharacters are not
89855008Scaelread, but merely perform flow control functions.  When
89955008Scael.Dv IXON
90055008Scaelis not set,
90155008Scaelthe
90255008Scael.Dv START
90355008Scaeland
90455008Scael.Dv STOP
90555008Scaelcharacters are read.
90655008Scael.Pp
90755008ScaelIf
90855008Scael.Dv IXOFF
90955008Scaelis set, start/stop input control is enabled.  The system shall
91055008Scaeltransmit one or more
91155008Scael.Dv STOP
91255008Scaelcharacters, which are intended to cause the
91351194Smarcterminal device to stop transmitting data, as needed to prevent the input
91451194Smarcqueue from overflowing and causing the undefined behavior described in
91555008Scael.Sx "Input Processing and Reading Data" ,
91655008Scaeland shall transmit one or more
91755008Scael.Dv START
91855008Scaelcharacters, which are
91951194Smarcintended to cause the terminal device to resume transmitting data, as
92051194Smarcsoon as the device can continue transmitting data without risk of
92155008Scaeloverflowing the input queue.  The precise conditions under which
92255008Scael.Dv STOP
92355008Scaeland
92455008ScaelSTART
92555008Scaelcharacters are transmitted are implementation defined.
92655008Scael.Pp
92755008ScaelIf
92855008Scael.Dv IMAXBEL
92966807Sbosticis set and the input queue is full, subsequent input shall cause 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
96964994Smckusickis set, tabs are expanded to the appropriate 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
98364994Smckusickfollowing masks.
98451194SmarcNot all values
98551194Smarcspecified are supported by all hardware.
98655008Scael.Pp
98755202Scael.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
104564994Smckusickis set, the receiver is enabled.  Otherwise, no character is
104664994Smckusickreceived.
104764994SmckusickNot all hardware supports this bit.  In fact, this flag
104855008Scaelis pretty silly and if it were not part of the
104955008Scael.Nm termios
105055008Scaelspecification
105164994Smckusickit would be omitted.
105255008Scael.Pp
105355008ScaelIf
105455008Scael.Dv PARENB
105564994Smckusickis set, parity generation and detection are enabled and a parity
105655008Scaelbit is added to each character.  If parity is enabled,
105755008Scael.Dv PARODD
105855008Scaelspecifies
105951194Smarcodd parity if set, otherwise even parity is used.
106055008Scael.Pp
106155008ScaelIf
106255008Scael.Dv HUPCL
106364994Smckusickis set, the modem control lines for the port are lowered
106451194Smarcwhen the last process with the port open closes the port or the process
106564994Smckusickterminates.  The modem connection is broken.
106655008Scael.Pp
106755008ScaelIf
106855008Scael.Dv CLOCAL
106955008Scaelis set, a connection does not depend on the state of the modem
107055008Scaelstatus lines.  If
107155008Scael.Dv CLOCAL
107264994Smckusickis clear, the modem status lines are
107351194Smarcmonitored.
107455008Scael.Pp
107564994SmckusickUnder normal circumstances, a call to the open() function waits for
107655008Scaelthe modem connection to complete.  However, if the
107755008Scael.Dv O_NONBLOCK
107855008Scaelflag is set
107955008Scaelor if
108055008Scael.Dv CLOCAL
108164994Smckusickhas been set, the open() function returns
108251194Smarcimmediately without waiting for the connection.
108355008Scael.Pp
108455008ScaelThe
108555008Scael.Dv CCTS_OFLOW
108655008Scael.Pf ( Dv CRTSCTS )
108755008Scaelflag is currently unused.
108855008Scael.Pp
108955008ScaelIf
109055008Scael.Dv MDMBUF
109155008Scaelis set then output flow control is controlled by the state
109251194Smarcof Carrier Detect.
109355008Scael.Pp
109451194SmarcIf the object for which the control modes are set is not an asynchronous
109551194Smarcserial connection, some of the modes may be ignored; for example, if an
109651194Smarcattempt is made to set the baud rate on a network connection to a
109751194Smarcterminal on another host, the baud rate may or may not be set on the
109851194Smarcconnection between that terminal and the machine it is directly connected
109951194Smarcto.
110055008Scael.Ss Local Modes
110164994SmckusickValues of the
110264994Smckusick.Fa c_lflag
110364994Smckusickfield describe the control of
110451194Smarcvarious functions, and are composed of the following
110555008Scaelmasks.
110655008Scael.Pp
110755008Scael.Bl -tag -width NOKERNINFO -offset indent -compact
110855008Scael.It Dv ECHOKE
110955008Scael/* visual erase for line kill */
111055008Scael.It Dv ECHOE
111155008Scael/* visually erase chars */
111255008Scael.It Dv ECHO
111355008Scael/* enable echoing */
111455008Scael.It Dv ECHONL
111555008Scael/* echo
111655008Scael.Dv NL
111755008Scaeleven if
111855008Scael.Dv ECHO
111955008Scaelis off */
112055008Scael.It Dv ECHOPRT
112155008Scael/* visual erase mode for hardcopy */
112255008Scael.It Dv ECHOCTL
112355008Scael/* echo control chars as ^(Char) */
112455008Scael.It Dv ISIG
112555008Scael/* enable signals
112655008Scael.Dv INTR ,
112755008Scael.Dv QUIT ,
112855008Scael.Dv [D]SUSP
112955008Scael*/
113055008Scael.It Dv ICANON
113155008Scael/* canonicalize input lines */
113255008Scael.It Dv ALTWERASE
113355008Scael/* use alternate
113455008Scael.Dv WERASE
113555008Scaelalgorithm */
113655008Scael.It Dv IEXTEN
113755008Scael/* enable
113855008Scael.Dv DISCARD
113955008Scaeland
114055008Scael.Dv LNEXT
114155008Scael*/
114255008Scael.It Dv EXTPROC
114355008Scael/* external processing */
114455008Scael.It Dv TOSTOP
114555008Scael/* stop background jobs from output */
114655008Scael.It Dv FLUSHO
114755008Scael/* output being flushed (state) */
114855008Scael.It Dv NOKERNINFO
114955008Scael/* no kernel output from
115055008Scael.Dv VSTATUS
115155008Scael*/
115255008Scael.It Dv PENDIN
115355008Scael/* XXX retype pending input (state) */
115455008Scael.It Dv NOFLSH
115555008Scael/* don't flush after interrupt */
115655008Scael.El
115755008Scael.Pp
115855008ScaelIf
115955008Scael.Dv ECHO
116055008Scaelis set, input characters are echoed back to the terminal.  If
116155008Scael.Dv ECHO
116255008Scaelis not set, input characters are not echoed.
116355008Scael.Pp
116455008ScaelIf
116555008Scael.Dv ECHOE
116655008Scaeland
116755008Scael.Dv ICANON
116855008Scaelare set, the
116955008Scael.Dv ERASE
117064994Smckusickcharacter causes the terminal
117151194Smarcto erase the last character in the current line from the display, if
117251194Smarcpossible.  If there is no character to erase, an implementation may echo
117351194Smarcan indication that this was the case or do nothing.
117455008Scael.Pp
117555008ScaelIf
117655008Scael.Dv ECHOK
117755008Scaeland
117855008Scael.Dv ICANON
117955008Scaelare set, the
118055008Scael.Dv KILL
118164994Smckusickcharacter causes
118264994Smckusickthe current line to be discarded and the system echoes the
118355008Scael.Ql \&\en
118455008Scaelcharacter after the
118555008Scael.Dv KILL
118655008Scaelcharacter.
118755008Scael.Pp
118855008ScaelIf
118955008Scael.Dv ECHOKE
119055008Scaeland
119155008Scael.Dv ICANON
119255008Scaelare set, the
119355008Scael.Dv KILL
119464994Smckusickcharacter causes
119564994Smckusickthe current line to be discarded and the system causes
119651194Smarcthe terminal
119751194Smarcto erase the line from the display.
119855008Scael.Pp
119955008ScaelIf
120055008Scael.Dv ECHOPRT
120155008Scaeland
120255008Scael.Dv ICANON
120364994Smckusickare set, the system assumes
120464994Smckusickthat the display is a printing device and prints a
120555008Scaelbackslash and the erased characters when processing
120655008Scael.Dv ERASE
120751194Smarccharacters, followed by a forward slash.
120855008Scael.Pp
120955008ScaelIf
121055008Scael.Dv ECHOCTL
121164994Smckusickis set, the system echoes control characters
121264994Smckusickin a visible fashion using a caret followed by the control character.
121355008Scael.Pp
121455008ScaelIf
121555008Scael.Dv ALTWERASE
121664994Smckusickis set, the system uses an alternative algorithm
121755008Scaelfor determining what constitutes a word when processing
121855008Scael.Dv WERASE
121955008Scaelcharacters (see
122055008Scael.Dv WERASE ) .
122155008Scael.Pp
122255008ScaelIf
122355008Scael.Dv ECHONL
122455008Scaeland
122555008Scael.Dv ICANON
122655008Scaelare set, the
122755008Scael.Ql \&\en
122864994Smckusickcharacter echoes even if
122955008Scael.Dv ECHO
123055008Scaelis not set.
123155008Scael.Pp
123255008ScaelIf
123355008Scael.Dv ICANON
123455008Scaelis set, canonical processing is enabled.  This enables the
123551194Smarcerase and kill edit functions, and the assembly of input characters into
123655008Scaellines delimited by
123755008Scael.Dv NL,
123855008Scael.Dv EOF ,
123955008Scaeland
124055008Scael.Dv EOL,
124155008Scaelas described in
124255008Scael.Sx "Canonical Mode Input Processing" .
124355008Scael.Pp
124455008ScaelIf
124555008Scael.Dv ICANON
124655008Scaelis not set, read requests are satisfied directly from the input
124764994Smckusickqueue.  A read is not satisfied until at least
124855008Scael.Dv MIN
124955008Scaelbytes have been
125055008Scaelreceived or the timeout value
125155008Scael.Dv TIME
125255008Scaelexpired between bytes.  The time value
125355008Scaelrepresents tenths of seconds.  See
125455008Scael.Sx "Noncanonical Mode Input Processing"
125551194Smarcfor more details.
125655008Scael.Pp
125755008ScaelIf
125855008Scael.Dv ISIG
125955008Scaelis set, each input character is checked against the special
126055008Scaelcontrol characters
126155008Scael.Dv INTR ,
126255008Scael.Dv QUIT ,
126355008Scaeland
126455008Scael.Dv SUSP
126555008Scael(job control only).  If an input
126651194Smarccharacter matches one of these control characters, the function
126755008Scaelassociated with that character is performed.  If
126855008Scael.Dv ISIG
126955008Scaelis not set, no
127051194Smarcchecking is done.  Thus these special input functions are possible only
127155008Scaelif
127255008Scael.Dv ISIG
127355008Scaelis set.
127455008Scael.Pp
127555008ScaelIf
127655008Scael.Dv IEXTEN
127764994Smckusickis set, implementation-defined functions are recognized
127864994Smckusickfrom the input data.  How
127955008Scael.Dv IEXTEN
128055008Scaelbeing set
128155008Scaelinteracts with
128255008Scael.Dv ICANON ,
128355008Scael.Dv ISIG ,
128455008Scael.Dv IXON ,
128555008Scaelor
128664994Smckusick.Dv IXOFF
128764994Smckusickis implementation defined.
128855008ScaelIf
128955008Scael.Dv IEXTEN
129055008Scaelis not set, then
129164994Smckusickimplementation-defined functions are not recognized, and the
129264994Smckusickcorresponding input characters are not processed as described for
129355008Scael.Dv ICANON ,
129455008Scael.Dv ISIG ,
129555008Scael.Dv IXON ,
129655008Scaeland
129755008Scael.Dv IXOFF .
129855008Scael.Pp
129955008ScaelIf
130055008Scael.Dv NOFLSH
130155008Scaelis set, the normal flush of the input and output queues
130255008Scaelassociated with the
130355008Scael.Dv INTR ,
130455008Scael.Dv QUIT ,
130555008Scaeland
130655008Scael.Dv SUSP
130755008Scaelcharacters
130864994Smckusickare not be done.
130955008Scael.Pp
131055008ScaelIf
131155008Scael.Dv TOSTOP
131255008Scaelis set, the signal
131355008Scael.Dv SIGTTOU
131455008Scaelis sent to the process group of a process that tries to write to
131551194Smarcits controlling terminal if it is not in the foreground process group for
131651194Smarcthat terminal.  This signal, by default, stops the members of the process
131751194Smarcgroup.  Otherwise, the output generated by that process is output to the
131855008Scaelcurrent output stream.  Processes that are blocking or ignoring
131955008Scael.Dv SIGTTOU
132055008Scaelsignals are excepted and allowed to produce output and the
132155008Scael.Dv SIGTTOU
132255008Scaelsignal
132351194Smarcis not sent.
132455008Scael.Pp
132555008ScaelIf
132655008Scael.Dv NOKERNINFO
132764994Smckusickis set, the kernel does not produce a status message
132855008Scaelwhen processing
132955008Scael.Dv STATUS
133055008Scaelcharacters (see
133155008Scael.Dv STATUS ) .
133255008Scael.Ss Special Control Characters
133364994SmckusickThe special control characters values are defined by the array
133464994Smckusick.Fa c_cc .
133551194SmarcThis table lists the array index, the corresponding special character,
133651194Smarcand the system default value.  For an accurate list of
133755008Scaelthe system defaults, consult the header file
133855008Scael.Aq Pa ttydefaults.h .
133955008Scael.Pp
134055008Scael.Bl -column "Index Name" "Special Character" -offset indent -compact
134155008Scael.It Em "Index Name	Special Character	Default Value"
134255008Scael.It Dv VEOF Ta EOF Ta \&^D
134355008Scael.It Dv VEOL Ta EOL Ta _POSIX_VDISABLE
134455008Scael.It Dv VEOL2 Ta EOL2 Ta _POSIX_VDISABLE
134555008Scael.It Dv VERASE Ta ERASE Ta \&^? Ql \&\e177
134655008Scael.It Dv VWERASE  Ta WERASE Ta \&^W
134755008Scael.It Dv VKILL Ta KILL Ta \&^U
134855008Scael.It Dv VREPRINT Ta REPRINT Ta \&^R
134955008Scael.It Dv VINTR Ta INTR Ta \&^C
135055008Scael.It Dv VQUIT Ta QUIT Ta \&^\e\e Ql \&\e34
135155008Scael.It Dv VSUSP Ta SUSP Ta \&^Z
135255008Scael.It Dv VDSUSP Ta DSUSP Ta \&^Y
135355008Scael.It Dv VSTART Ta START Ta \&^Q
135455008Scael.It Dv VSTOP Ta STOP Ta \&^S
135555008Scael.It Dv VLNEXT Ta LNEXT Ta \&^V
135655008Scael.It Dv VDISCARD Ta DISCARD Ta \&^O
135755008Scael.It Dv VMIN Ta --- Ta \&1
135855008Scael.It Dv VTIME Ta --- Ta \&0
135955008Scael.It Dv VSTATUS Ta STATUS Ta \&^T
136055008Scael.El
136155008Scael.Pp
136251194SmarcIf the
136355008Scaelvalue of one of the changeable special control characters (see
136455008Scael.Sx "Special Characters" )
136555008Scaelis
136655008Scael.Dv {_POSIX_VDISABLE} ,
136764994Smckusickthat function is disabled; that is, no input
136864994Smckusickdata is recognized as the disabled special character.
136955008ScaelIf
137055008Scael.Dv ICANON
137155008Scaelis
137255008Scaelnot set, the value of
137355008Scael.Dv {_POSIX_VDISABLE}
137455008Scaelhas no special meaning for the
137555008Scael.Dv VMIN
137655008Scaeland
137755008Scael.Dv VTIME
137855008Scaelentries of the
137955008Scael.Fa c_cc
138055008Scaelarray.
138155008Scael.Pp
138255008ScaelThe initial values of the flags and control characters
138351194Smarcafter open() is set according to
138455008Scaelthe values in the header
138555008Scael.Aq Pa sys/ttydefaults.h .
1386