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*64994Smckusick.\" @(#)termios.4 8.2 (Berkeley) 11/30/93 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 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, 90*64994Smckusickand 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 108*64994Smckusickis 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 20355008Scaelis a sent an 20455008Scael.Tn ASCII 20555008Scael.Dv BEL 206*64994Smckusickcharacter 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 251*64994Smckusick.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 430*64994Smckusickhave 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 614*64994Smckusicknon-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 647*64994Smckusicksignal 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. 689*64994SmckusickAny 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 729*64994Smckusick.Fa c_lflag . 730*64994SmckusickThe 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 813*64994Smckusickerror (other than break) is given to the application as the 814*64994Smckusickthree-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 862*64994Smckusick.Dv NL 863*64994Smckusickcharacter 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 92955008Scaelis set and the input queue is full, subsequent input 93055008Scaelshall causes an 93155008Scael.Tn ASCII 93255008Scael.Dv BEL 93355008Scaelcharacter to be transmitted to the 93451194Smarcthe output queue. 93555008Scael.Pp 93651194SmarcThe initial input control value after open() is implementation defined. 93755008Scael.Ss Output Modes 93855008ScaelValues of the 93955008Scael.Fa c_oflag 94055008Scaelfield describe the basic terminal output control, 94151194Smarcand are composed of the following masks: 94255008Scael.Pp 94355008Scael.Bl -tag -width OXTABS -offset indent -compact 94455008Scael.It Dv OPOST 94555008Scael/* enable following output processing */ 94655008Scael.It Dv ONLCR 94755008Scael/* map NL to CR-NL (ala 94855008Scael.Dv CRMOD) 94955008Scael*/ 95055008Scael.It Dv OXTABS 95155008Scael/* expand tabs to spaces */ 95255008Scael.It Dv ONOEOT 95355008Scael/* discard 95455008Scael.Dv EOT Ns 's 95555008Scael.Ql \&^D 95655008Scaelon output) */ 95755008Scael.El 95855008Scael.Pp 95955008ScaelIf 96055008Scael.Dv OPOST 96155008Scaelis set, the remaining flag masks are interpreted as follows; 96251194Smarcotherwise characters are transmitted without change. 96355008Scael.Pp 96455008ScaelIf 96555008Scael.Dv ONLCR 96655008Scaelis set, newlines are translated to carriage return, linefeeds. 96755008Scael.Pp 96855008ScaelIf 96955008Scael.Dv OXTABS 970*64994Smckusickis set, tabs are expanded to the appropriate number of 97151194Smarcspaces (assuming 8 column tab stops). 97255008Scael.Pp 97355008ScaelIf 97455008Scael.Dv ONOEOT 97555008Scaelis set, 97655008Scael.Tn ASCII 97755008Scael.Dv EOT NS 's 97855008Scaelare discarded on output. 97955008Scael.Ss Control Modes 98055008ScaelValues of the 98155008Scael.Fa c_cflag 98255008Scaelfield describe the basic 98355008Scaelterminal hardware control, and are composed of the 984*64994Smckusickfollowing masks. 98551194SmarcNot all values 98651194Smarcspecified are supported by all hardware. 98755008Scael.Pp 98855202Scael.Bl -tag -width CRTSXIFLOW -offset indent -compact 98955008Scael.It Dv CSIZE 99055008Scael/* character size mask */ 99155008Scael.It Dv CS5 99255008Scael/* 5 bits (pseudo) */ 99355008Scael.It Dv CS6 99455008Scael/* 6 bits */ 99555008Scael.It Dv CS7 99655008Scael/* 7 bits */ 99755008Scael.It Dv CS8 99855008Scael/* 8 bits */ 99955008Scael.It Dv CSTOPB 100055008Scael/* send 2 stop bits */ 100155008Scael.It Dv CREAD 100255008Scael/* enable receiver */ 100355008Scael.It Dv PARENB 100455008Scael/* parity enable */ 100555008Scael.It Dv PARODD 100655008Scael/* odd parity, else even */ 100755008Scael.It Dv HUPCL 100855008Scael/* hang up on last close */ 100955008Scael.It Dv CLOCAL 101055008Scael/* ignore modem status lines */ 101155008Scael.It Dv CCTS_OFLOW 101255008Scael/* 101355008Scael.Dv CTS 101455008Scaelflow control of output */ 101555008Scael.It Dv CRTSCTS 101655008Scael/* same as 101755008Scael.Dv CCTS_OFLOW 101855008Scael*/ 101955008Scael.It Dv CRTS_IFLOW 102055008Scael/* RTS flow control of input */ 102155008Scael.It Dv MDMBUF 102255008Scael/* flow control output via Carrier */ 102355008Scael.El 102455008Scael.Pp 102555008ScaelThe 102655008Scael.Dv CSIZE 102755008Scaelbits specify the byte size in bits for both transmission and 102855008Scaelreception. The 102955008Scael.Fa c_cflag 103055008Scaelis masked with 103155008Scael.Dv CSIZE 103255008Scaeland compared with the 103355008Scaelvalues 103455008Scael.Dv CS5 , 103555008Scael.Dv CS6 , 103655008Scael.Dv CS7 , 103755008Scaelor 103855008Scael.Dv CS8 . 103955008ScaelThis size does not include the parity bit, if any. If 104055008Scael.Dv CSTOPB 104151194Smarcis set, two stop bits are used, otherwise one stop bit. For example, at 104251194Smarc110 baud, two stop bits are normally used. 104355008Scael.Pp 104455008ScaelIf 104555008Scael.Dv CREAD 1046*64994Smckusickis set, the receiver is enabled. Otherwise, no character is 1047*64994Smckusickreceived. 1048*64994SmckusickNot all hardware supports this bit. In fact, this flag 104955008Scaelis pretty silly and if it were not part of the 105055008Scael.Nm termios 105155008Scaelspecification 1052*64994Smckusickit would be omitted. 105355008Scael.Pp 105455008ScaelIf 105555008Scael.Dv PARENB 1056*64994Smckusickis set, parity generation and detection are enabled and a parity 105755008Scaelbit is added to each character. If parity is enabled, 105855008Scael.Dv PARODD 105955008Scaelspecifies 106051194Smarcodd parity if set, otherwise even parity is used. 106155008Scael.Pp 106255008ScaelIf 106355008Scael.Dv HUPCL 1064*64994Smckusickis set, the modem control lines for the port are lowered 106551194Smarcwhen the last process with the port open closes the port or the process 1066*64994Smckusickterminates. The modem connection is broken. 106755008Scael.Pp 106855008ScaelIf 106955008Scael.Dv CLOCAL 107055008Scaelis set, a connection does not depend on the state of the modem 107155008Scaelstatus lines. If 107255008Scael.Dv CLOCAL 1073*64994Smckusickis clear, the modem status lines are 107451194Smarcmonitored. 107555008Scael.Pp 1076*64994SmckusickUnder normal circumstances, a call to the open() function waits for 107755008Scaelthe modem connection to complete. However, if the 107855008Scael.Dv O_NONBLOCK 107955008Scaelflag is set 108055008Scaelor if 108155008Scael.Dv CLOCAL 1082*64994Smckusickhas been set, the open() function returns 108351194Smarcimmediately without waiting for the connection. 108455008Scael.Pp 108555008ScaelThe 108655008Scael.Dv CCTS_OFLOW 108755008Scael.Pf ( Dv CRTSCTS ) 108855008Scaelflag is currently unused. 108955008Scael.Pp 109055008ScaelIf 109155008Scael.Dv MDMBUF 109255008Scaelis set then output flow control is controlled by the state 109351194Smarcof Carrier Detect. 109455008Scael.Pp 109551194SmarcIf the object for which the control modes are set is not an asynchronous 109651194Smarcserial connection, some of the modes may be ignored; for example, if an 109751194Smarcattempt is made to set the baud rate on a network connection to a 109851194Smarcterminal on another host, the baud rate may or may not be set on the 109951194Smarcconnection between that terminal and the machine it is directly connected 110051194Smarcto. 110155008Scael.Ss Local Modes 1102*64994SmckusickValues of the 1103*64994Smckusick.Fa c_lflag 1104*64994Smckusickfield describe the control of 110551194Smarcvarious functions, and are composed of the following 110655008Scaelmasks. 110755008Scael.Pp 110855008Scael.Bl -tag -width NOKERNINFO -offset indent -compact 110955008Scael.It Dv ECHOKE 111055008Scael/* visual erase for line kill */ 111155008Scael.It Dv ECHOE 111255008Scael/* visually erase chars */ 111355008Scael.It Dv ECHO 111455008Scael/* enable echoing */ 111555008Scael.It Dv ECHONL 111655008Scael/* echo 111755008Scael.Dv NL 111855008Scaeleven if 111955008Scael.Dv ECHO 112055008Scaelis off */ 112155008Scael.It Dv ECHOPRT 112255008Scael/* visual erase mode for hardcopy */ 112355008Scael.It Dv ECHOCTL 112455008Scael/* echo control chars as ^(Char) */ 112555008Scael.It Dv ISIG 112655008Scael/* enable signals 112755008Scael.Dv INTR , 112855008Scael.Dv QUIT , 112955008Scael.Dv [D]SUSP 113055008Scael*/ 113155008Scael.It Dv ICANON 113255008Scael/* canonicalize input lines */ 113355008Scael.It Dv ALTWERASE 113455008Scael/* use alternate 113555008Scael.Dv WERASE 113655008Scaelalgorithm */ 113755008Scael.It Dv IEXTEN 113855008Scael/* enable 113955008Scael.Dv DISCARD 114055008Scaeland 114155008Scael.Dv LNEXT 114255008Scael*/ 114355008Scael.It Dv EXTPROC 114455008Scael/* external processing */ 114555008Scael.It Dv TOSTOP 114655008Scael/* stop background jobs from output */ 114755008Scael.It Dv FLUSHO 114855008Scael/* output being flushed (state) */ 114955008Scael.It Dv NOKERNINFO 115055008Scael/* no kernel output from 115155008Scael.Dv VSTATUS 115255008Scael*/ 115355008Scael.It Dv PENDIN 115455008Scael/* XXX retype pending input (state) */ 115555008Scael.It Dv NOFLSH 115655008Scael/* don't flush after interrupt */ 115755008Scael.El 115855008Scael.Pp 115955008ScaelIf 116055008Scael.Dv ECHO 116155008Scaelis set, input characters are echoed back to the terminal. If 116255008Scael.Dv ECHO 116355008Scaelis not set, input characters are not echoed. 116455008Scael.Pp 116555008ScaelIf 116655008Scael.Dv ECHOE 116755008Scaeland 116855008Scael.Dv ICANON 116955008Scaelare set, the 117055008Scael.Dv ERASE 1171*64994Smckusickcharacter causes the terminal 117251194Smarcto erase the last character in the current line from the display, if 117351194Smarcpossible. If there is no character to erase, an implementation may echo 117451194Smarcan indication that this was the case or do nothing. 117555008Scael.Pp 117655008ScaelIf 117755008Scael.Dv ECHOK 117855008Scaeland 117955008Scael.Dv ICANON 118055008Scaelare set, the 118155008Scael.Dv KILL 1182*64994Smckusickcharacter causes 1183*64994Smckusickthe current line to be discarded and the system echoes the 118455008Scael.Ql \&\en 118555008Scaelcharacter after the 118655008Scael.Dv KILL 118755008Scaelcharacter. 118855008Scael.Pp 118955008ScaelIf 119055008Scael.Dv ECHOKE 119155008Scaeland 119255008Scael.Dv ICANON 119355008Scaelare set, the 119455008Scael.Dv KILL 1195*64994Smckusickcharacter causes 1196*64994Smckusickthe current line to be discarded and the system causes 119751194Smarcthe terminal 119851194Smarcto erase the line from the display. 119955008Scael.Pp 120055008ScaelIf 120155008Scael.Dv ECHOPRT 120255008Scaeland 120355008Scael.Dv ICANON 1204*64994Smckusickare set, the system assumes 1205*64994Smckusickthat the display is a printing device and prints a 120655008Scaelbackslash and the erased characters when processing 120755008Scael.Dv ERASE 120851194Smarccharacters, followed by a forward slash. 120955008Scael.Pp 121055008ScaelIf 121155008Scael.Dv ECHOCTL 1212*64994Smckusickis set, the system echoes control characters 1213*64994Smckusickin a visible fashion using a caret followed by the control character. 121455008Scael.Pp 121555008ScaelIf 121655008Scael.Dv ALTWERASE 1217*64994Smckusickis set, the system uses an alternative algorithm 121855008Scaelfor determining what constitutes a word when processing 121955008Scael.Dv WERASE 122055008Scaelcharacters (see 122155008Scael.Dv WERASE ) . 122255008Scael.Pp 122355008ScaelIf 122455008Scael.Dv ECHONL 122555008Scaeland 122655008Scael.Dv ICANON 122755008Scaelare set, the 122855008Scael.Ql \&\en 1229*64994Smckusickcharacter echoes even if 123055008Scael.Dv ECHO 123155008Scaelis not set. 123255008Scael.Pp 123355008ScaelIf 123455008Scael.Dv ICANON 123555008Scaelis set, canonical processing is enabled. This enables the 123651194Smarcerase and kill edit functions, and the assembly of input characters into 123755008Scaellines delimited by 123855008Scael.Dv NL, 123955008Scael.Dv EOF , 124055008Scaeland 124155008Scael.Dv EOL, 124255008Scaelas described in 124355008Scael.Sx "Canonical Mode Input Processing" . 124455008Scael.Pp 124555008ScaelIf 124655008Scael.Dv ICANON 124755008Scaelis not set, read requests are satisfied directly from the input 1248*64994Smckusickqueue. A read is not satisfied until at least 124955008Scael.Dv MIN 125055008Scaelbytes have been 125155008Scaelreceived or the timeout value 125255008Scael.Dv TIME 125355008Scaelexpired between bytes. The time value 125455008Scaelrepresents tenths of seconds. See 125555008Scael.Sx "Noncanonical Mode Input Processing" 125651194Smarcfor more details. 125755008Scael.Pp 125855008ScaelIf 125955008Scael.Dv ISIG 126055008Scaelis set, each input character is checked against the special 126155008Scaelcontrol characters 126255008Scael.Dv INTR , 126355008Scael.Dv QUIT , 126455008Scaeland 126555008Scael.Dv SUSP 126655008Scael(job control only). If an input 126751194Smarccharacter matches one of these control characters, the function 126855008Scaelassociated with that character is performed. If 126955008Scael.Dv ISIG 127055008Scaelis not set, no 127151194Smarcchecking is done. Thus these special input functions are possible only 127255008Scaelif 127355008Scael.Dv ISIG 127455008Scaelis set. 127555008Scael.Pp 127655008ScaelIf 127755008Scael.Dv IEXTEN 1278*64994Smckusickis set, implementation-defined functions are recognized 1279*64994Smckusickfrom the input data. How 128055008Scael.Dv IEXTEN 128155008Scaelbeing set 128255008Scaelinteracts with 128355008Scael.Dv ICANON , 128455008Scael.Dv ISIG , 128555008Scael.Dv IXON , 128655008Scaelor 1287*64994Smckusick.Dv IXOFF 1288*64994Smckusickis implementation defined. 128955008ScaelIf 129055008Scael.Dv IEXTEN 129155008Scaelis not set, then 1292*64994Smckusickimplementation-defined functions are not recognized, and the 1293*64994Smckusickcorresponding input characters are not processed as described for 129455008Scael.Dv ICANON , 129555008Scael.Dv ISIG , 129655008Scael.Dv IXON , 129755008Scaeland 129855008Scael.Dv IXOFF . 129955008Scael.Pp 130055008ScaelIf 130155008Scael.Dv NOFLSH 130255008Scaelis set, the normal flush of the input and output queues 130355008Scaelassociated with the 130455008Scael.Dv INTR , 130555008Scael.Dv QUIT , 130655008Scaeland 130755008Scael.Dv SUSP 130855008Scaelcharacters 1309*64994Smckusickare not be done. 131055008Scael.Pp 131155008ScaelIf 131255008Scael.Dv TOSTOP 131355008Scaelis set, the signal 131455008Scael.Dv SIGTTOU 131555008Scaelis sent to the process group of a process that tries to write to 131651194Smarcits controlling terminal if it is not in the foreground process group for 131751194Smarcthat terminal. This signal, by default, stops the members of the process 131851194Smarcgroup. Otherwise, the output generated by that process is output to the 131955008Scaelcurrent output stream. Processes that are blocking or ignoring 132055008Scael.Dv SIGTTOU 132155008Scaelsignals are excepted and allowed to produce output and the 132255008Scael.Dv SIGTTOU 132355008Scaelsignal 132451194Smarcis not sent. 132555008Scael.Pp 132655008ScaelIf 132755008Scael.Dv NOKERNINFO 1328*64994Smckusickis set, the kernel does not produce a status message 132955008Scaelwhen processing 133055008Scael.Dv STATUS 133155008Scaelcharacters (see 133255008Scael.Dv STATUS ) . 133355008Scael.Ss Special Control Characters 1334*64994SmckusickThe special control characters values are defined by the array 1335*64994Smckusick.Fa c_cc . 133651194SmarcThis table lists the array index, the corresponding special character, 133751194Smarcand the system default value. For an accurate list of 133855008Scaelthe system defaults, consult the header file 133955008Scael.Aq Pa ttydefaults.h . 134055008Scael.Pp 134155008Scael.Bl -column "Index Name" "Special Character" -offset indent -compact 134255008Scael.It Em "Index Name Special Character Default Value" 134355008Scael.It Dv VEOF Ta EOF Ta \&^D 134455008Scael.It Dv VEOL Ta EOL Ta _POSIX_VDISABLE 134555008Scael.It Dv VEOL2 Ta EOL2 Ta _POSIX_VDISABLE 134655008Scael.It Dv VERASE Ta ERASE Ta \&^? Ql \&\e177 134755008Scael.It Dv VWERASE Ta WERASE Ta \&^W 134855008Scael.It Dv VKILL Ta KILL Ta \&^U 134955008Scael.It Dv VREPRINT Ta REPRINT Ta \&^R 135055008Scael.It Dv VINTR Ta INTR Ta \&^C 135155008Scael.It Dv VQUIT Ta QUIT Ta \&^\e\e Ql \&\e34 135255008Scael.It Dv VSUSP Ta SUSP Ta \&^Z 135355008Scael.It Dv VDSUSP Ta DSUSP Ta \&^Y 135455008Scael.It Dv VSTART Ta START Ta \&^Q 135555008Scael.It Dv VSTOP Ta STOP Ta \&^S 135655008Scael.It Dv VLNEXT Ta LNEXT Ta \&^V 135755008Scael.It Dv VDISCARD Ta DISCARD Ta \&^O 135855008Scael.It Dv VMIN Ta --- Ta \&1 135955008Scael.It Dv VTIME Ta --- Ta \&0 136055008Scael.It Dv VSTATUS Ta STATUS Ta \&^T 136155008Scael.El 136255008Scael.Pp 136351194SmarcIf the 136455008Scaelvalue of one of the changeable special control characters (see 136555008Scael.Sx "Special Characters" ) 136655008Scaelis 136755008Scael.Dv {_POSIX_VDISABLE} , 1368*64994Smckusickthat function is disabled; that is, no input 1369*64994Smckusickdata is recognized as the disabled special character. 137055008ScaelIf 137155008Scael.Dv ICANON 137255008Scaelis 137355008Scaelnot set, the value of 137455008Scael.Dv {_POSIX_VDISABLE} 137555008Scaelhas no special meaning for the 137655008Scael.Dv VMIN 137755008Scaeland 137855008Scael.Dv VTIME 137955008Scaelentries of the 138055008Scael.Fa c_cc 138155008Scaelarray. 138255008Scael.Pp 138355008ScaelThe initial values of the flags and control characters 138451194Smarcafter open() is set according to 138555008Scaelthe values in the header 138655008Scael.Aq Pa sys/ttydefaults.h . 1387