1.\" Copyright (c) 1991, 1992, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)termios.4 8.4 (Berkeley) 4/19/94 29.\" $FreeBSD: head/share/man/man4/termios.4 263142 2014-03-14 03:07:51Z eadler $ 30.\" 31.Dd November 1, 2019 32.Dt TERMIOS 4 33.Os 34.Sh NAME 35.Nm termios 36.Nd general terminal line discipline 37.Sh SYNOPSIS 38.In termios.h 39.Sh DESCRIPTION 40This describes a general terminal line discipline that is 41supported on tty asynchronous communication ports. 42.Ss Opening a Terminal Device File 43When a terminal file is opened, it normally causes the process to wait 44until a connection is established. 45For most hardware, the presence 46of a connection is indicated by the assertion of the hardware 47.Dv CARRIER 48line. 49If the termios structure associated with the terminal file has the 50.Dv CLOCAL 51flag set in the cflag, or if the 52.Dv O_NONBLOCK 53flag is set 54in the 55.Xr open 2 56call, then the open will succeed even without 57a connection being present. 58In practice, applications 59seldom open these files; they are opened by special programs, such 60as 61.Xr getty 8 62or 63.Xr rlogind 8 Pq Pa net/bsdrcmds , 64and become 65an application's standard input, output, and error files. 66.Ss Job Control in a Nutshell 67Every process is associated with a particular process group and session. 68The grouping is hierarchical: every member of a particular process group is a 69member of the same session. 70This structuring is used in managing groups 71of related processes for purposes of 72.\" .Gw "job control" ; 73.Em "job control" ; 74that is, the 75ability from the keyboard (or from program control) to simultaneously 76stop or restart 77a complex command (a command composed of one or more related 78processes). 79The grouping into process groups allows delivering 80of signals that stop or start the group as a whole, along with 81arbitrating which process group has access to the single controlling 82terminal. 83The grouping at a higher layer into sessions is to restrict 84the job control related signals and system calls to within processes 85resulting from a particular instance of a 86.Dq login . 87Typically, a session 88is created when a user logs in, and the login terminal is setup 89to be the controlling terminal; all processes spawned from that 90login shell are in the same session, and inherit the controlling 91terminal. 92.Pp 93A job control shell 94operating interactively (that is, reading commands from a terminal) 95normally groups related processes together by placing them into the 96same process group. 97A set of processes in the same process group is collectively referred to as a 98.Dq job . 99When the foreground process 100group of the terminal is the same as the process group of a particular 101job, that job is said to be in the 102.Dq foreground . 103When the process group of the terminal is different from the process group of 104a job (but is still the controlling terminal), that job is said 105to be in the 106.Dq background . 107Normally the 108shell reads a command and starts the job that implements that 109command. 110If the command is to be started in the foreground (typical), it 111sets the process group of the terminal to the process group 112of the started job, waits for the job to complete, and then 113sets the process group of the terminal back to its own process 114group (it puts itself into the foreground). 115If the job is to 116be started in the background (as denoted by the shell operator "&"), 117it never changes the process group of the terminal and does not 118wait for the job to complete (that is, it immediately attempts to read the next 119command). 120If the job is started in the foreground, the user may 121type a key (usually 122.Ql \&^Z ) 123which generates the terminal stop signal 124.Pq Dv SIGTSTP 125and has the effect of stopping the entire job. 126The shell will notice that the job stopped, and will resume running after 127placing itself in the foreground. 128The shell also has commands for placing stopped jobs in the background, 129and for placing stopped or background jobs into the foreground. 130.Ss Orphaned Process Groups 131An orphaned process group is a process group that has no process 132whose parent is in a different process group, yet is in the same 133session. 134Conceptually it means a process group that does not have 135a parent that could do anything if it were to be stopped. 136For example, 137the initial login shell is typically in an orphaned process group. 138Orphaned process groups are immune to keyboard generated stop 139signals and job control signals resulting from reads or writes to the 140controlling terminal. 141.Ss The Controlling Terminal 142A terminal may belong to a process as its controlling terminal. 143Each process of a session that has a controlling terminal has the same 144controlling terminal. 145A terminal may be the controlling terminal for at most one session. 146The controlling terminal for a session is allocated by 147the session leader by issuing the 148.Dv TIOCSCTTY 149ioctl. 150A controlling terminal 151is never acquired by merely opening a terminal device file. 152When a controlling terminal becomes 153associated with a session, its foreground process group is set to 154the process group of the session leader. 155.Pp 156The controlling terminal is inherited by a child process during a 157.Xr fork 2 158function call. 159A process relinquishes its controlling terminal when it 160creates a new session with the 161.Xr setsid 2 162function; other processes 163remaining in the old session that had this terminal as their controlling 164terminal continue to have it. 165A process does not relinquish its 166controlling terminal simply by closing all of its file descriptors 167associated with the controlling terminal if other processes continue to 168have it open. 169.Pp 170When a controlling process terminates, the controlling terminal is 171disassociated from the current session, allowing it to be acquired by a 172new session leader. 173Subsequent access to the terminal by other processes 174in the earlier session will be denied, with attempts to access the 175terminal treated as if modem disconnect had been sensed. 176.Ss Terminal Access Control 177If a process is in the foreground process group of its controlling 178terminal, read operations are allowed. 179Any attempts by a process 180in a background process group to read from its controlling terminal 181causes a 182.Dv SIGTTIN 183signal to be sent to 184the process's group 185unless one of the 186following special cases apply: if the reading process is ignoring or 187blocking the 188.Dv SIGTTIN 189signal, or if the process group of the reading 190process is orphaned, the 191.Xr read 2 192returns -1 with 193.Va errno 194set to 195.Er EIO 196and no 197signal is sent. 198The default action of the 199.Dv SIGTTIN 200signal is to stop the 201process to which it is sent. 202.Pp 203If a process is in the foreground process group of its controlling 204terminal, write operations are allowed. 205Attempts by a process in a background process group to write to its 206controlling terminal will cause the process group to be sent a 207.Dv SIGTTOU 208signal unless one of the following special cases apply: if 209.Dv TOSTOP 210is not 211set, or if 212.Dv TOSTOP 213is set and the process is ignoring or blocking the 214.Dv SIGTTOU 215signal, the process is allowed to write to the terminal and the 216.Dv SIGTTOU 217signal is not sent. 218If 219.Dv TOSTOP 220is set, and the process group of 221the writing process is orphaned, and the writing process is not ignoring 222or blocking 223.Dv SIGTTOU , 224the 225.Xr write 2 226returns -1 with 227.Va errno 228set to 229.Er EIO 230and no signal is sent. 231.Pp 232Certain calls that set terminal parameters are treated in the same 233fashion as write, except that 234.Dv TOSTOP 235is ignored; that is, the effect is 236identical to that of terminal writes when 237.Dv TOSTOP 238is set. 239.Ss Input Processing and Reading Data 240A terminal device associated with a terminal device file may operate in 241full-duplex mode, so that data may arrive even while output is occurring. 242Each terminal device file has associated with it an input queue, into 243which incoming data is stored by the system before being read by a 244process. 245The system imposes a limit, 246.Pf \&{ Dv MAX_INPUT Ns \&} , 247on the number of bytes that may be stored in the input queue. 248The behavior of the system 249when this limit is exceeded depends on the setting of the 250.Dv IMAXBEL 251flag in the termios 252.Fa c_iflag . 253If this flag is set, the terminal 254is sent an 255.Tn ASCII 256.Dv BEL 257character each time a character is received 258while the input queue is full. 259Otherwise, the input queue is flushed upon receiving the character. 260.Pp 261Two general kinds of input processing are available, determined by 262whether the terminal device file is in canonical mode or noncanonical 263mode. 264Additionally, 265input characters are processed according to the 266.Fa c_iflag 267and 268.Fa c_lflag 269fields. 270Such processing can include echoing, which 271in general means transmitting input characters immediately back to the 272terminal when they are received from the terminal. 273This is useful for terminals that can operate in full-duplex mode. 274.Pp 275The manner in which data is provided to a process reading from a terminal 276device file is dependent on whether the terminal device file is in 277canonical or noncanonical mode. 278.Pp 279Another dependency is whether the 280.Dv O_NONBLOCK 281flag is set by 282.Xr open 2 283or 284.Xr fcntl 2 . 285If the 286.Dv O_NONBLOCK 287flag is clear, then the read request is 288blocked until data is available or a signal has been received. 289If the 290.Dv O_NONBLOCK 291flag is set, then the read request is completed, without 292blocking, in one of three ways: 293.Bl -enum -offset indent 294.It 295If there is enough data available to satisfy the entire request, 296and the read completes successfully the number of 297bytes read is returned. 298.It 299If there is not enough data available to satisfy the entire 300request, and the read completes successfully, having read as 301much data as possible, the number of bytes read is returned. 302.It 303If there is no data available, the read returns -1, with 304.Va errno 305set to 306.Er EAGAIN . 307.El 308.Pp 309When data is available depends on whether the input processing mode is 310canonical or noncanonical. 311.Ss Canonical Mode Input Processing 312In canonical mode input processing, terminal input is processed in units 313of lines. 314A line is delimited by a newline 315.Ql \&\en 316character, an end-of-file 317.Pq Dv EOF 318character, or an end-of-line 319.Pq Dv EOL 320character. 321See the 322.Sx "Special Characters" 323section for more information on 324.Dv EOF 325and 326.Dv EOL . 327This means that a read request will 328not return until an entire line has been typed, or a signal has been 329received. 330Also, no matter how many bytes are requested in the read call, 331at most one line is returned. 332It is not, however, necessary to 333read a whole line at once; any number of bytes, even one, may be 334requested in a read without losing information. 335.Pp 336.Pf \&{ Dv MAX_CANON Ns \&} 337is a limit on the 338number of bytes in a line. 339The behavior of the system when this limit is 340exceeded is the same as when the input queue limit 341.Pf \&{ Dv MAX_INPUT Ns \&} , 342is exceeded. 343.Pp 344Erase and kill processing occur when either of two special characters, 345the 346.Dv ERASE 347and 348.Dv KILL 349characters (see the 350.Sx "Special Characters" 351section), is received. 352This processing affects data in the input queue that has not yet been 353delimited by a newline 354.Dv NL , 355.Dv EOF , 356or 357.Dv EOL 358character. 359This un-delimited data makes up the current line. 360The 361.Dv ERASE 362character deletes the last character in the current line, if there is any. 363The 364.Dv KILL 365character 366deletes all data in the current line, if there is any. 367The 368.Dv ERASE 369and 370.Dv KILL 371characters have no effect if there is no data in the current line. 372The 373.Dv ERASE 374and 375.Dv KILL 376characters themselves are not placed in the input 377queue. 378.Ss Noncanonical Mode Input Processing 379In noncanonical mode input processing, input bytes are not assembled into 380lines, and erase and kill processing does not occur. 381The values of the 382.Dv VMIN 383and 384.Dv VTIME 385members of the 386.Fa c_cc 387array are used to determine how to 388process the bytes received. 389.Pp 390.Dv MIN 391represents the minimum number of bytes that should be received when 392the 393.Xr read 2 394function successfully returns. 395.Dv TIME 396is a timer of 0.1 second 397granularity that is used to time out bursty and short term data 398transmissions. 399If 400.Dv MIN 401is greater than 402.Dv \&{ Dv MAX_INPUT Ns \&} , 403the response to the 404request is undefined. 405The four possible values for 406.Dv MIN 407and 408.Dv TIME 409and 410their interactions are described below. 411.Ss "Case A: MIN > 0, TIME > 0" 412In this case 413.Dv TIME 414serves as an inter-byte timer and is activated after 415the first byte is received. 416Since it is an inter-byte timer, it is reset after a byte is received. 417The interaction between 418.Dv MIN 419and 420.Dv TIME 421is as 422follows: as soon as one byte is received, the inter-byte timer is 423started. 424If 425.Dv MIN 426bytes are received before the inter-byte timer expires 427(remember that the timer is reset upon receipt of each byte), the read is 428satisfied. 429If the timer expires before 430.Dv MIN 431bytes are received, the 432characters received to that point are returned to the user. 433Note that if 434.Dv TIME 435expires at least one byte is returned because the timer would 436not have been enabled unless a byte was received. 437In this case 438.Pf \&( Dv MIN 439> 0, 440.Dv TIME 441> 0) the read blocks until the 442.Dv MIN 443and 444.Dv TIME 445mechanisms are 446activated by the receipt of the first byte, or a signal is received. 447If data is in the buffer at the time of the 448.Fn read , 449the result is as 450if data had been received immediately after the 451.Fn read . 452.Ss "Case B: MIN > 0, TIME = 0" 453In this case, since the value of 454.Dv TIME 455is zero, the timer plays no role 456and only 457.Dv MIN 458is significant. 459A pending read is not satisfied until 460.Dv MIN 461bytes are received (i.e., the pending read blocks until 462.Dv MIN 463bytes 464are received), or a signal is received. 465A program that uses this case to read record-based terminal 466.Dv I/O 467may block indefinitely in the read 468operation. 469.Ss "Case C: MIN = 0, TIME > 0" 470In this case, since 471.Dv MIN 472= 0, 473.Dv TIME 474no longer represents an inter-byte 475timer. 476It now serves as a read timer that is activated as soon as the 477read function is processed. 478A read is satisfied as soon as a single 479byte is received or the read timer expires. 480Note that in this case if the timer expires, no bytes are returned. 481If the timer does not 482expire, the only way the read can be satisfied is if a byte is received. 483In this case the read will not block indefinitely waiting for a byte; if 484no byte is received within 485.Dv TIME Ns *0.1 486seconds after the read is initiated, 487the read returns a value of zero, having read no data. 488If data is in the buffer at the time of the read, the timer is started as if 489data had been received immediately after the read. 490.Ss Case D: MIN = 0, TIME = 0 491The minimum of either the number of bytes requested or the number of 492bytes currently available is returned without waiting for more 493bytes to be input. 494If no characters are available, read returns a 495value of zero, having read no data. 496.Ss Writing Data and Output Processing 497When a process writes one or more bytes to a terminal device file, they 498are processed according to the 499.Fa c_oflag 500field (see the 501.Sx "Output Modes" 502section). 503The implementation may provide a buffering mechanism; as such, when a call to 504.Fn write 505completes, all of the bytes written have been scheduled for 506transmission to the device, but the transmission will not necessarily 507have been completed. 508.\" See also .Sx "6.4.2" for the effects of 509.\" .Dv O_NONBLOCK 510.\" on write. 511.Ss Special Characters 512Certain characters have special functions on input or output or both. 513These functions are summarized as follows: 514.Bl -tag -width indent 515.It Dv INTR 516Special character on input and is recognized if the 517.Dv ISIG 518flag (see the 519.Sx "Local Modes" 520section) is enabled. 521Generates a 522.Dv SIGINT 523signal which is sent to all processes in the foreground 524process group for which the terminal is the controlling terminal. 525If 526.Dv ISIG 527is set, the 528.Dv INTR 529character is 530discarded when processed. 531.It Dv QUIT 532Special character on input and is recognized if the 533.Dv ISIG 534flag is enabled. 535Generates a 536.Dv SIGQUIT 537signal which is sent to all processes in the foreground process group 538for which the terminal is the controlling terminal. 539If 540.Dv ISIG 541is set, the 542.Dv QUIT 543character is discarded when 544processed. 545.It Dv ERASE 546Special character on input and is recognized if the 547.Dv ICANON 548flag is set. 549Erases the last character in the current line; see 550.Sx "Canonical Mode Input Processing" . 551It does not erase beyond 552the start of a line, as delimited by an 553.Dv NL , 554.Dv EOF , 555or 556.Dv EOL 557character. 558If 559.Dv ICANON 560is set, the 561.Dv ERASE 562character is 563discarded when processed. 564.It Dv KILL 565Special character on input and is recognized if the 566.Dv ICANON 567flag is set. 568Deletes the entire line, as delimited by a 569.Dv NL , 570.Dv EOF , 571or 572.Dv EOL 573character. 574If 575.Dv ICANON 576is set, the 577.Dv KILL 578character is discarded when processed. 579.It Dv EOF 580Special character on input and is recognized if the 581.Dv ICANON 582flag is set. 583When received, all the bytes waiting to be read are immediately passed to the 584process, without waiting for a newline, and the 585.Dv EOF 586is discarded. 587Thus, if there are no bytes waiting (that is, the 588.Dv EOF 589occurred at the beginning of a line), a byte 590count of zero is returned from the 591.Fn read , 592representing an end-of-file indication. 593If 594.Dv ICANON 595is 596set, the 597.Dv EOF 598character is discarded when processed. 599.It Dv NL 600Special character on input and is recognized if the 601.Dv ICANON 602flag is set. 603It is the line delimiter 604.Ql \&\en . 605.It Dv EOL 606Special character on input and is recognized if the 607.Dv ICANON 608flag is set. 609Is an additional line delimiter, like 610.Dv NL . 611.It Dv SUSP 612If the 613.Dv ISIG 614flag is enabled, receipt of the 615.Dv SUSP 616character causes a 617.Dv SIGTSTP 618signal to be sent to all processes in the 619foreground process group for which the terminal is the 620controlling terminal, and the 621.Dv SUSP 622character is 623discarded when processed. 624.It Dv STOP 625Special character on both input and output and is 626recognized if the 627.Dv IXON 628(output control) or 629.Dv IXOFF 630(input 631control) flag is set. 632Can be used to temporarily suspend output. 633It is useful with fast terminals to 634prevent output from disappearing before it can be read. 635If 636.Dv IXON 637is set, the 638.Dv STOP 639character is discarded when 640processed. 641.It Dv START 642Special character on both input and output and is 643recognized if the 644.Dv IXON 645(output control) or 646.Dv IXOFF 647(input 648control) flag is set. 649Can be used to resume output that has been suspended by a 650.Dv STOP 651character. 652If 653.Dv IXON 654is set, the 655.Dv START 656character is discarded when processed. 657.It Dv CR 658Special character on input and is recognized if the 659.Dv ICANON 660flag is set; it is the 661.Ql \&\er , 662as denoted in the 663.Tn \&C 664Standard {2}. 665When 666.Dv ICANON 667and 668.Dv ICRNL 669are set and 670.Dv IGNCR 671is not set, this character is translated into a 672.Dv NL , 673and 674has the same effect as a 675.Dv NL 676character. 677.El 678.Pp 679The following special characters are extensions defined by this 680system and are not a part of 681.St -p1003.1 682termios. 683.Bl -tag -width indent 684.It Dv EOL2 685Secondary 686.Dv EOL 687character. 688Same function as 689.Dv EOL . 690.It Dv WERASE 691Special character on input and is recognized if the 692.Dv ICANON 693flag is set. 694Erases the last word in the current line according to one of two algorithms. 695If the 696.Dv ALTWERASE 697flag is not set, first any preceding whitespace is 698erased, and then the maximal sequence of non-whitespace 699characters. 700If 701.Dv ALTWERASE 702is set, first any preceding 703whitespace is erased, and then the maximal sequence 704of alphabetic/underscores or non alphabetic/underscores. 705As a special case in this second algorithm, the first previous 706non-whitespace character is skipped in determining 707whether the preceding word is a sequence of 708alphabetic/underscores. 709This sounds confusing but turns out to be quite practical. 710.It Dv REPRINT 711Special character on input and is recognized if the 712.Dv ICANON 713flag is set. 714Causes the current input edit line to be retyped. 715.It Dv DSUSP 716Has similar actions to the 717.Dv SUSP 718character, except that 719the 720.Dv SIGTSTP 721signal is delivered when one of the processes 722in the foreground process group issues a 723.Fn read 724to the 725controlling terminal. 726.It Dv LNEXT 727Special character on input and is recognized if the 728.Dv IEXTEN 729flag is set. 730Receipt of this character causes the next character to be taken literally. 731.It Dv DISCARD 732Special character on input and is recognized if the 733.Dv IEXTEN 734flag is set. 735Receipt of this character toggles the flushing of terminal output. 736.It Dv STATUS 737Special character on input and is recognized if the 738.Dv ICANON 739flag is set. 740Receipt of this character causes a 741.Dv SIGINFO 742signal to be sent to the foreground process group of the terminal. 743Also, if the 744.Dv NOKERNINFO 745flag is not set, it 746causes the kernel to write a status message to the terminal 747that displays the current load average, the name of the 748command in the foreground, its process ID, the symbolic 749wait channel, the number of user and system seconds used, 750the percentage of cpu the process is getting, and the resident 751set size of the process. 752.El 753.Pp 754The 755.Dv NL 756and 757.Dv CR 758characters cannot be changed. 759The values for all the remaining characters can be set and are 760described later in the document under 761Special Control Characters. 762.Pp 763Special 764character functions associated with changeable special control characters 765can be disabled individually by setting their value to 766.Dv {_POSIX_VDISABLE} ; 767see 768.Sx "Special Control Characters" . 769.Pp 770If two or more special characters have the same value, the function 771performed when that character is received is undefined. 772.Ss Modem Disconnect 773If a modem disconnect is detected by the terminal interface for a 774controlling terminal, and if 775.Dv CLOCAL 776is not set in the 777.Fa c_cflag 778field for 779the terminal, the 780.Dv SIGHUP 781signal is sent to the controlling 782process associated with the terminal. 783Unless other arrangements have 784been made, this causes the controlling process to terminate. 785Any subsequent call to the 786.Fn read 787function returns the value zero, 788indicating end of file. 789Thus, processes that read a terminal 790file and test for end-of-file can terminate appropriately after a 791disconnect. 792.\" If the 793.\" .Er EIO 794.\" condition specified in 6.1.1.4 that applies 795.\" when the implementation supports job control also exists, it is 796.\" unspecified whether the 797.\" .Dv EOF 798.\" condition or the 799.\" .Pf [ Er EIO 800.\" ] is returned. 801Any 802subsequent 803.Fn write 804to the terminal device returns -1, with 805.Va errno 806set to 807.Er EIO , 808until the device is closed. 809.Sh General Terminal Interface 810.Ss Closing a Terminal Device File 811The last process to close a terminal device file causes any output 812to be sent to the device and any input to be discarded. 813Then, if 814.Dv HUPCL 815is set in the control modes, and the communications port supports a 816disconnect function, the terminal device performs a disconnect. 817.Ss Parameters That Can Be Set 818Routines that need to control certain terminal 819.Tn I/O 820characteristics 821do so by using the termios structure as defined in the header 822.In termios.h . 823This structure contains minimally four scalar elements of bit flags 824and one array of special characters. 825The scalar flag elements are named: 826.Fa c_iflag , 827.Fa c_oflag , 828.Fa c_cflag , 829and 830.Fa c_lflag . 831The character array is named 832.Fa c_cc , 833and its maximum index is 834.Dv NCCS . 835.Ss Input Modes 836Values of the 837.Fa c_iflag 838field describe the basic 839terminal input control, and are composed of 840following masks: 841.Pp 842.Bl -tag -width IMAXBEL -offset indent -compact 843.It Dv IGNBRK 844/* ignore BREAK condition */ 845.It Dv BRKINT 846/* map BREAK to SIGINTR */ 847.It Dv IGNPAR 848/* ignore (discard) parity errors */ 849.It Dv PARMRK 850/* mark parity and framing errors */ 851.It Dv INPCK 852/* enable checking of parity errors */ 853.It Dv ISTRIP 854/* strip 8th bit off chars */ 855.It Dv INLCR 856/* map NL into CR */ 857.It Dv IGNCR 858/* ignore CR */ 859.It Dv ICRNL 860/* map CR to NL (ala CRMOD) */ 861.It Dv IXON 862/* enable output flow control */ 863.It Dv IXOFF 864/* enable input flow control */ 865.It Dv IXANY 866/* any char will restart after stop */ 867.It Dv IMAXBEL 868/* ring bell on input queue full */ 869.El 870.Pp 871In the context of asynchronous serial data transmission, a break 872condition is defined as a sequence of zero-valued bits that continues for 873more than the time to send one byte. 874The entire sequence of zero-valued 875bits is interpreted as a single break condition, even if it continues for 876a time equivalent to more than one byte. 877In contexts other than 878asynchronous serial data transmission the definition of a break condition 879is implementation defined. 880.Pp 881If 882.Dv IGNBRK 883is set, a break condition detected on input is ignored, that 884is, not put on the input queue and therefore not read by any process. 885If 886.Dv IGNBRK 887is not set and 888.Dv BRKINT 889is set, the break condition flushes the 890input and output queues and if the terminal is the controlling terminal 891of a foreground process group, the break condition generates a 892single 893.Dv SIGINT 894signal to that foreground process group. 895If neither 896.Dv IGNBRK 897nor 898.Dv BRKINT 899is set, a break condition is read as a single 900.Ql \&\e0 , 901or if 902.Dv PARMRK 903is set, as 904.Ql \&\e377 , 905.Ql \&\e0 , 906.Ql \&\e0 . 907.Pp 908If 909.Dv IGNPAR 910is set, a byte with a framing or parity error (other than 911break) is ignored. 912.Pp 913If 914.Dv PARMRK 915is set, and 916.Dv IGNPAR 917is not set, a byte with a framing or parity 918error (other than break) is given to the application as the 919three-character sequence 920.Ql \&\e377 , 921.Ql \&\e0 , 922X, where 923.Ql \&\e377 , 924.Ql \&\e0 925is a two-character 926flag preceding each sequence and X is the data of the character received 927in error. 928To avoid ambiguity in this case, if 929.Dv ISTRIP 930is not set, a valid 931character of 932.Ql \&\e377 933is given to the application as 934.Ql \&\e377 , 935.Ql \&\e377 . 936If 937neither 938.Dv PARMRK 939nor 940.Dv IGNPAR 941is set, a framing or parity error (other than 942break) is given to the application as a single character 943.Ql \&\e0 . 944.Pp 945If 946.Dv INPCK 947is set, input parity checking is enabled. 948If 949.Dv INPCK 950is not set, 951input parity checking is disabled, allowing output parity generation 952without input parity errors. 953Note that whether input parity checking is 954enabled or disabled is independent of whether parity detection is enabled 955or disabled (see 956.Sx "Control Modes" ) . 957If parity detection is enabled but input 958parity checking is disabled, the hardware to which the terminal is 959connected recognizes the parity bit, but the terminal special file 960does not check whether this bit is set correctly or not. 961.Pp 962If 963.Dv ISTRIP 964is set, valid input bytes are first stripped to seven bits, 965otherwise all eight bits are processed. 966.Pp 967If 968.Dv INLCR 969is set, a received 970.Dv NL 971character is translated into a 972.Dv CR 973character. 974If 975.Dv IGNCR 976is set, a received 977.Dv CR 978character is ignored (not 979read). 980If 981.Dv IGNCR 982is not set and 983.Dv ICRNL 984is set, a received 985.Dv CR 986character is 987translated into a 988.Dv NL 989character. 990.Pp 991If 992.Dv IXON 993is set, start/stop output control is enabled. 994A received 995.Dv STOP 996character suspends output and a received 997.Dv START 998character 999restarts output. 1000If 1001.Dv IXANY 1002is also set, then any character may 1003restart output. 1004When 1005.Dv IXON 1006is set, 1007.Dv START 1008and 1009.Dv STOP 1010characters are not read, but merely perform flow control functions. 1011When 1012.Dv IXON 1013is not set, 1014the 1015.Dv START 1016and 1017.Dv STOP 1018characters are read. 1019.Pp 1020If 1021.Dv IXOFF 1022is set, start/stop input control is enabled. 1023The system shall transmit one or more 1024.Dv STOP 1025characters, which are intended to cause the 1026terminal device to stop transmitting data, as needed to prevent the input 1027queue from overflowing and causing the undefined behavior described in 1028.Sx "Input Processing and Reading Data" , 1029and shall transmit one or more 1030.Dv START 1031characters, which are 1032intended to cause the terminal device to resume transmitting data, as 1033soon as the device can continue transmitting data without risk of 1034overflowing the input queue. 1035The precise conditions under which 1036.Dv STOP 1037and 1038.Dv START 1039characters are transmitted are implementation defined. 1040.Pp 1041If 1042.Dv IMAXBEL 1043is set and the input queue is full, subsequent input shall cause an 1044.Tn ASCII 1045.Dv BEL 1046character to be transmitted to 1047the output queue. 1048.Pp 1049The initial input control value after 1050.Fn open 1051is implementation defined. 1052.Ss Output Modes 1053Values of the 1054.Fa c_oflag 1055field describe the basic terminal output control, 1056and are composed of the following masks: 1057.Pp 1058.Bl -tag -width OXTABS -offset indent -compact 1059.It Dv OPOST 1060/* enable following output processing */ 1061.It Dv ONLCR 1062/* map NL to CR-NL (ala 1063.Dv CRMOD ) 1064*/ 1065.It Dv OCRNL 1066/* map CR to NL */ 1067.It Dv TABDLY 1068/* tab delay mask */ 1069.It Dv TAB0 1070/* no tab delay and expansion */ 1071.It Dv TAB3 1072/* expand tabs to spaces */ 1073.It Dv OXTABS 1074/* alias for TAB3 */ 1075.It Dv ONOEOT 1076/* discard 1077.Dv EOT Ns 's 1078.Ql \&^D 1079on output) */ 1080.It Dv ONOCR 1081/* do not transmit CRs on column 0 */ 1082.It Dv ONLRET 1083/* on the terminal NL performs the CR function */ 1084.El 1085.Pp 1086If 1087.Dv OPOST 1088is set, the remaining flag masks are interpreted as follows; 1089otherwise characters are transmitted without change. 1090.Pp 1091If 1092.Dv ONLCR 1093is set, newlines are translated to carriage return, linefeeds. 1094.Pp 1095If 1096.Dv OCRNL 1097is set, carriage returns are translated to newlines. 1098.Pp 1099The 1100.Dv TABDLY 1101bits specify the tab delay. 1102The 1103.Fa c_oflag 1104is masked with 1105.Dv TABDLY 1106and compared with the 1107values 1108.Dv TAB0 1109or 1110.Dv TAB3 . 1111If 1112.Dv TAB3 1113or 1114.Dv OXTABS 1115is set, tabs are expanded to the appropriate number of 1116spaces (assuming 8 column tab stops). 1117.Pp 1118If 1119.Dv ONOEOT 1120is set, 1121.Tn ASCII 1122.Dv EOT Ns 's 1123are discarded on output. 1124.Pp 1125If 1126.Dv ONOCR 1127is set, no CR character is transmitted when at column 0 (first position). 1128.Pp 1129If 1130.Dv ONLRET 1131is set, the NL character is assumed to do the carriage-return function; 1132the column pointer will be set to 0. 1133.Ss Control Modes 1134Values of the 1135.Fa c_cflag 1136field describe the basic 1137terminal hardware control, and are composed of the 1138following masks. 1139Not all values 1140specified are supported by all hardware. 1141.Pp 1142.Bl -tag -width CRTSXIFLOW -offset indent -compact 1143.It Dv CSIZE 1144/* character size mask */ 1145.It Dv CS5 1146/* 5 bits (pseudo) */ 1147.It Dv CS6 1148/* 6 bits */ 1149.It Dv CS7 1150/* 7 bits */ 1151.It Dv CS8 1152/* 8 bits */ 1153.It Dv CSTOPB 1154/* send 2 stop bits */ 1155.It Dv CREAD 1156/* enable receiver */ 1157.It Dv PARENB 1158/* parity enable */ 1159.It Dv PARODD 1160/* odd parity, else even */ 1161.It Dv HUPCL 1162/* hang up on last close */ 1163.It Dv CLOCAL 1164/* ignore modem status lines */ 1165.It Dv CCTS_OFLOW 1166/* 1167.Dv CTS 1168flow control of output */ 1169.It Dv CRTSCTS 1170/* same as 1171.Dv CCTS_OFLOW 1172*/ 1173.It Dv CRTS_IFLOW 1174/* RTS flow control of input */ 1175.It Dv MDMBUF 1176/* flow control output via Carrier */ 1177.El 1178.Pp 1179The 1180.Dv CSIZE 1181bits specify the byte size in bits for both transmission and reception. 1182The 1183.Fa c_cflag 1184is masked with 1185.Dv CSIZE 1186and compared with the 1187values 1188.Dv CS5 , 1189.Dv CS6 , 1190.Dv CS7 , 1191or 1192.Dv CS8 . 1193This size does not include the parity bit, if any. 1194If 1195.Dv CSTOPB 1196is set, two stop bits are used, otherwise one stop bit. 1197For example, at 110 baud, two stop bits are normally used. 1198.Pp 1199If 1200.Dv CREAD 1201is set, the receiver is enabled. 1202Otherwise, no character is received. 1203Not all hardware supports this bit. 1204In fact, this flag is pretty silly and if it were not part of the 1205.Nm 1206specification 1207it would be omitted. 1208.Pp 1209If 1210.Dv PARENB 1211is set, parity generation and detection are enabled and a parity 1212bit is added to each character. 1213If parity is enabled, 1214.Dv PARODD 1215specifies odd parity if set, otherwise even parity is used. 1216.Pp 1217If 1218.Dv HUPCL 1219is set, the modem control lines for the port are lowered 1220when the last process with the port open closes the port or the process 1221terminates. 1222The modem connection is broken. 1223.Pp 1224If 1225.Dv CLOCAL 1226is set, a connection does not depend on the state of the modem 1227status lines. 1228If 1229.Dv CLOCAL 1230is clear, the modem status lines are monitored. 1231.Pp 1232Under normal circumstances, a call to the 1233.Fn open 1234function waits for the modem connection to complete. 1235However, if the 1236.Dv O_NONBLOCK 1237flag is set or if 1238.Dv CLOCAL 1239has been set, the 1240.Fn open 1241function returns 1242immediately without waiting for the connection. 1243.Pp 1244The 1245.Dv CCTS_OFLOW 1246.Pf ( Dv CRTSCTS ) 1247flag is currently unused. 1248.Pp 1249If 1250.Dv MDMBUF 1251is set then output flow control is controlled by the state 1252of Carrier Detect. 1253.Pp 1254If the object for which the control modes are set is not an asynchronous 1255serial connection, some of the modes may be ignored; for example, if an 1256attempt is made to set the baud rate on a network connection to a 1257terminal on another host, the baud rate may or may not be set on the 1258connection between that terminal and the machine it is directly connected 1259to. 1260.Ss Local Modes 1261Values of the 1262.Fa c_lflag 1263field describe the control of 1264various functions, and are composed of the following 1265masks. 1266.Pp 1267.Bl -tag -width NOKERNINFO -offset indent -compact 1268.It Dv ECHOKE 1269/* visual erase for line kill */ 1270.It Dv ECHOE 1271/* visually erase chars */ 1272.It Dv ECHO 1273/* enable echoing */ 1274.It Dv ECHONL 1275/* echo 1276.Dv NL 1277even if 1278.Dv ECHO 1279is off */ 1280.It Dv ECHOPRT 1281/* visual erase mode for hardcopy */ 1282.It Dv ECHOCTL 1283/* echo control chars as ^(Char) */ 1284.It Dv ISIG 1285/* enable signals 1286.Dv INTR , 1287.Dv QUIT , 1288.Dv [D]SUSP 1289*/ 1290.It Dv ICANON 1291/* canonicalize input lines */ 1292.It Dv ALTWERASE 1293/* use alternate 1294.Dv WERASE 1295algorithm */ 1296.It Dv IEXTEN 1297/* enable 1298.Dv DISCARD 1299and 1300.Dv LNEXT 1301*/ 1302.It Dv EXTPROC 1303/* external processing */ 1304.It Dv TOSTOP 1305/* stop background jobs from output */ 1306.It Dv FLUSHO 1307/* output being flushed (state) */ 1308.It Dv NOKERNINFO 1309/* no kernel output from 1310.Dv VSTATUS 1311*/ 1312.It Dv PENDIN 1313/* XXX retype pending input (state) */ 1314.It Dv NOFLSH 1315/* don't flush after interrupt */ 1316.El 1317.Pp 1318If 1319.Dv ECHO 1320is set, input characters are echoed back to the terminal. 1321If 1322.Dv ECHO 1323is not set, input characters are not echoed. 1324.Pp 1325If 1326.Dv ECHOE 1327and 1328.Dv ICANON 1329are set, the 1330.Dv ERASE 1331character causes the terminal 1332to erase the last character in the current line from the display, if 1333possible. 1334If there is no character to erase, an implementation may echo 1335an indication that this was the case or do nothing. 1336.Pp 1337If 1338.Dv ECHOK 1339and 1340.Dv ICANON 1341are set, the 1342.Dv KILL 1343character causes 1344the current line to be discarded and the system echoes the 1345.Ql \&\en 1346character after the 1347.Dv KILL 1348character. 1349.Pp 1350If 1351.Dv ECHOKE 1352and 1353.Dv ICANON 1354are set, the 1355.Dv KILL 1356character causes 1357the current line to be discarded and the system causes 1358the terminal 1359to erase the line from the display. 1360.Pp 1361If 1362.Dv ECHOPRT 1363and 1364.Dv ICANON 1365are set, the system assumes 1366that the display is a printing device and prints a 1367backslash and the erased characters when processing 1368.Dv ERASE 1369characters, followed by a forward slash. 1370.Pp 1371If 1372.Dv ECHOCTL 1373is set, the system echoes control characters 1374in a visible fashion using a caret followed by the control character. 1375.Pp 1376If 1377.Dv ALTWERASE 1378is set, the system uses an alternative algorithm 1379for determining what constitutes a word when processing 1380.Dv WERASE 1381characters (see 1382.Dv WERASE ) . 1383.Pp 1384If 1385.Dv ECHONL 1386and 1387.Dv ICANON 1388are set, the 1389.Ql \&\en 1390character echoes even if 1391.Dv ECHO 1392is not set. 1393.Pp 1394If 1395.Dv ICANON 1396is set, canonical processing is enabled. 1397This enables the 1398erase and kill edit functions, and the assembly of input characters into 1399lines delimited by 1400.Dv NL , 1401.Dv EOF , 1402and 1403.Dv EOL , 1404as described in 1405.Sx "Canonical Mode Input Processing" . 1406.Pp 1407If 1408.Dv ICANON 1409is not set, read requests are satisfied directly from the input queue. 1410A read is not satisfied until at least 1411.Dv MIN 1412bytes have been 1413received or the timeout value 1414.Dv TIME 1415expired between bytes. 1416The time value represents tenths of seconds. 1417See 1418.Sx "Noncanonical Mode Input Processing" 1419for more details. 1420.Pp 1421If 1422.Dv ISIG 1423is set, each input character is checked against the special 1424control characters 1425.Dv INTR , 1426.Dv QUIT , 1427and 1428.Dv SUSP 1429(job control only). 1430If an input character matches one of these control characters, the function 1431associated with that character is performed. 1432If 1433.Dv ISIG 1434is not set, no checking is done. 1435Thus these special input functions are possible only if 1436.Dv ISIG 1437is set. 1438.Pp 1439If 1440.Dv IEXTEN 1441is set, implementation-defined functions are recognized from the input data. 1442How 1443.Dv IEXTEN 1444being set 1445interacts with 1446.Dv ICANON , 1447.Dv ISIG , 1448.Dv IXON , 1449or 1450.Dv IXOFF 1451is implementation defined. 1452If 1453.Dv IEXTEN 1454is not set, then 1455implementation-defined functions are not recognized, and the 1456corresponding input characters are not processed as described for 1457.Dv ICANON , 1458.Dv ISIG , 1459.Dv IXON , 1460and 1461.Dv IXOFF . 1462.Pp 1463If 1464.Dv NOFLSH 1465is set, the normal flush of the input and output queues 1466associated with the 1467.Dv INTR , 1468.Dv QUIT , 1469and 1470.Dv SUSP 1471characters 1472are not be done. 1473.Pp 1474If 1475.Dv TOSTOP 1476is set, the signal 1477.Dv SIGTTOU 1478is sent to the process group of a process that tries to write to 1479its controlling terminal if it is not in the foreground process group for 1480that terminal. 1481This signal, by default, stops the members of the process group. 1482Otherwise, the output generated by that process is output to the 1483current output stream. 1484Processes that are blocking or ignoring 1485.Dv SIGTTOU 1486signals are excepted and allowed to produce output and the 1487.Dv SIGTTOU 1488signal 1489is not sent. 1490.Pp 1491If 1492.Dv NOKERNINFO 1493is set, the kernel does not produce a status message 1494when processing 1495.Dv STATUS 1496characters (see 1497.Dv STATUS ) . 1498.Ss Special Control Characters 1499The special control characters values are defined by the array 1500.Fa c_cc . 1501This table lists the array index, the corresponding special character, 1502and the system default value. 1503For an accurate list of the system defaults, consult the header file 1504.In sys/ttydefaults.h . 1505.Pp 1506.Bl -column "Index Name" "Special Character" -offset indent -compact 1507.It Em "Index Name Special Character Default Value" 1508.It Dv VEOF Ta EOF Ta \&^D 1509.It Dv VEOL Ta EOL Ta _POSIX_VDISABLE 1510.It Dv VEOL2 Ta EOL2 Ta _POSIX_VDISABLE 1511.It Dv VERASE Ta ERASE Ta \&^? Ql \&\e177 1512.It Dv VWERASE Ta WERASE Ta \&^W 1513.It Dv VKILL Ta KILL Ta \&^U 1514.It Dv VREPRINT Ta REPRINT Ta \&^R 1515.It Dv VINTR Ta INTR Ta \&^C 1516.It Dv VQUIT Ta QUIT Ta \&^\e\e Ql \&\e34 1517.It Dv VSUSP Ta SUSP Ta \&^Z 1518.It Dv VDSUSP Ta DSUSP Ta \&^Y 1519.It Dv VSTART Ta START Ta \&^Q 1520.It Dv VSTOP Ta STOP Ta \&^S 1521.It Dv VLNEXT Ta LNEXT Ta \&^V 1522.It Dv VDISCARD Ta DISCARD Ta \&^O 1523.It Dv VMIN Ta --- Ta \&1 1524.It Dv VTIME Ta --- Ta \&0 1525.It Dv VSTATUS Ta STATUS Ta \&^T 1526.El 1527.Pp 1528If the 1529value of one of the changeable special control characters (see 1530.Sx "Special Characters" ) 1531is 1532.Dv {_POSIX_VDISABLE} , 1533that function is disabled; that is, no input 1534data is recognized as the disabled special character. 1535If 1536.Dv ICANON 1537is 1538not set, the value of 1539.Dv {_POSIX_VDISABLE} 1540has no special meaning for the 1541.Dv VMIN 1542and 1543.Dv VTIME 1544entries of the 1545.Fa c_cc 1546array. 1547.Pp 1548The initial values of the flags and control characters 1549after 1550.Fn open 1551is set according to 1552the values in the header 1553.In sys/ttydefaults.h . 1554.Sh SEE ALSO 1555.Xr stty 1 , 1556.Xr tcgetsid 3 , 1557.Xr tcsendbreak 3 , 1558.Xr tcsetattr 3 , 1559.Xr tcsetsid 3 , 1560.Xr tty 4 1561