The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 General Terminal Interface

This chapter describes a general terminal interface that is provided to control asynchronous communications ports. It is implementation-dependent whether it supports network connections or synchronous ports or both.

 Interface Characteristics

 Opening a Terminal Device File

When a terminal device file is opened, it normally causes the thread to wait until a connection is established. In practice, application programs seldom open these files; they are opened by special programs and become an application's standard input, output and error files.

As described in open(), opening a terminal device file with the O_NONBLOCK flag clear causes the thread to block until the terminal device is ready and available. If CLOCAL mode is not set, this means blocking until a connection is established. If CLOCAL mode is set in the terminal, or the O_NONBLOCK flag is specified in the open(), the open() function returns a file descriptor without waiting for a connection to be established.

 Process Groups

A terminal may have a foreground process group associated with it. This foreground process group plays a special role in handling signal-generating input characters, as discussed in Special Characters .

A command interpreter process supporting job control can allocate the terminal to different jobs, or process groups, by placing related processes in a single process group and associating this process group with the terminal. A terminal's foreground process group may be set or examined by a process, assuming the permission requirements are met; see tcgetpgrp() and tcsetpgrp(). The terminal interface aids in this allocation by restricting access to the terminal by processes that are not in the current process group; see Terminal Access Control .

When there is no longer any process whose process ID or process group ID matches the process group ID of the foreground process group, the terminal will have no foreground process group. It is unspecified whether the terminal has a foreground process group when there is a process whose process ID matches the foreground process ID, but whose process group ID does not. No actions defined in this specification set, other than allocation of a controlling terminal or a successful call to tcsetpgrp(), will cause a process group to become the foreground process group of the terminal.

 The Controlling Terminal

A terminal may belong to a process as its controlling terminal. Each process of a session that has a controlling terminal has the same controlling terminal. A terminal may be the controlling terminal for at most one session. The controlling terminal for a session is allocated by the session leader in an implementation-dependent manner. If a session leader has no controlling terminal, and opens a terminal device file that is not already associated with a session without using the O_NOCTTY option (see open()), it is implementation-dependent whether the terminal becomes the controlling terminal of the session leader. If a process which is not a session leader opens a terminal file, or the O_NOCTTY option is used on open(), then that terminal does not become the controlling terminal of the calling process. When a controlling terminal becomes associated with a session, its foreground process group is set to the process group of the session leader.

The controlling terminal is inherited by a child process during a fork() function call. A process relinquishes its controlling terminal when it creates a new session with the setsid() function; other processes remaining in the old session that had this terminal as their controlling terminal continue to have it. Upon the close of the last file descriptor in the system (whether or not it is in the current session) associated with the controlling terminal, it is unspecified whether all processes that had that terminal as their controlling terminal cease to have any controlling terminal. Whether and how a session leader can reacquire a controlling terminal after the controlling terminal has been relinquished in this fashion is unspecified. A process does not relinquish its controlling terminal simply by closing all of its file descriptors associated with the controlling terminal if other processes continue to have it open.

When a controlling process terminates, the controlling terminal is dissociated from the current session, allowing it to be acquired by a new session leader. Subsequent access to the terminal by other processes in the earlier session may be denied, with attempts to access the terminal treated as if a modem disconnect had been sensed.

 Terminal Access Control

If a process is in the foreground process group of its controlling terminal, read operations are allowed, as described in Input Processing and Reading Data . Any attempts by a process in a background process group to read from its controlling terminal cause its process group to be sent a SIGTTIN signal unless one of the following special cases applies: if the reading process is ignoring or blocking the SIGTTIN signal, or if the process group of the reading process is orphaned, the read() returns -1, with errno set to [EIO] and no signal is sent. The default action of the SIGTTIN signal is to stop the process to which it is sent. See <signal.h>.

If a process is in the foreground process group of its controlling terminal, write operations are allowed as described in Writing Data and Output Processing . Attempts by a process in a background process group to write to its controlling terminal will cause the process group to be sent a SIGTTOU signal unless one of the following special cases applies: if TOSTOP is not set, or if TOSTOP is set and the process is ignoring or blocking the SIGTTOU signal, the process is allowed to write to the terminal and the SIGTTOU signal is not sent. If TOSTOP is set, and the process group of the writing process is orphaned, and the writing process is not ignoring or blocking the SIGTTOU signal, the write() returns -1, with errno set to [EIO] and no signal is sent.

Certain calls that set terminal parameters are treated in the same fashion as write(), except that TOSTOP is ignored; that is, the effect is identical to that of terminal writes when TOSTOP is set (see Local Modes , tcdrain(), tcflow(), tcflush(), tcsendbreak(), tcsetattr() and tcsetpgrp()).

 Input Processing and Reading Data

A terminal device associated with a terminal device file may operate in full-duplex mode, so that data may arrive even while output is occurring. Each terminal device file has an associated with it, into which incoming data is stored by the system before being read by a process. The system may impose a limit, {MAX_INPUT}, on the number of bytes that may be stored in the input queue. The behaviour of the system when this limit is exceeded is implementation-dependent.

Two general kinds of input processing are available, determined by whether the terminal device file is in canonical mode or non-canonical mode. These modes are described in Canonical Mode Input Processing and Non-canonical Mode Input Processing . Additionally, input characters are processed according to the c_iflag (see Input Modes ) and c_lflag (see Local Modes ) fields. Such processing can include which in general means transmitting input characters immediately back to the terminal when they are received from the terminal. This is useful for terminals that can operate in full-duplex mode.

The manner in which data is provided to a process reading from a terminal device file is dependent on whether the terminal file is in canonical or non-canonical mode, and on whether or not the O_NONBLOCK flag is set by open() or fcntl().

If the O_NONBLOCK flag is clear, then the read request is blocked until data is available or a signal has been received. If the O_NONBLOCK flag is set, then the read request is completed, without blocking, in one of three ways:

  1. If there is enough data available to satisfy the entire request, the read() completes successfully and returns the number of bytes read.

  2. If there is not enough data available to satisfy the entire request, the read() completes successfully, having read as much data as possible, and returns the number of bytes it was able to read.

  3. If there is no data available, the read() returns -1, with errno set to [EAGAIN].

When data is available depends on whether the input processing mode is canonical or non-canonical. The following sections, Canonical Mode Input Processing and Non-canonical Mode Input Processing describe each of these input processing modes.

 Canonical Mode Input Processing

In canonical mode input processing, terminal input is processed in units of lines. A line is delimited by a newline character (NL), an end-of-file character (EOF), or an end-of-line (EOL) character. See Special Characters for more information on EOF and EOL. This means that a read request will not return until an entire line has been typed or a signal has been received. Also, no matter how many bytes are requested in the read() call, at most one line will be returned. It is not, however, necessary to read a whole line at once; any number of bytes, even one, may be requested in a read() without losing information.

If {MAX_CANON} is defined for this terminal device, it is a limit on the number of bytes in a line. The behaviour of the system when this limit is exceeded is implementation-dependent. If {MAX_CANON} is not defined, there is no such limit; see pathconf().

Erase and kill processing occur when either of two special characters, the ERASE and KILL characters (see Special Characters ), is received. This processing affects data in the input queue that has not yet been delimited by a newline (NL), EOF or EOL character. This un-delimited data makes up the current line. The ERASE character deletes the last character in the current line, if there is one. The KILL character deletes all data in the current line, if there are any. The ERASE and KILL characters have no effect if there is no data in the current line. The ERASE and KILL characters themselves are not placed in the input queue.

 Non-canonical Mode Input Processing

In non-canonical mode input processing, input bytes are not assembled into lines, and erase and kill processing does not occur. The values of the MIN and TIME members of the c_cc array are used to determine how to process the bytes received. The ISO POSIX-1 standard does not specify whether the setting of O_NONBLOCK takes precedence over MIN or TIME settings. Therefore, if O_NONBLOCK is set, read() may return immediately, regardless of the setting of MIN or TIME. Also, if no data is available, read() may either return 0, or return -1 with errno set to [EAGAIN].

MIN represents the minimum number of bytes that should be received when the read() function returns successfully. TIME is a timer of 0.1 second granularity that is used to time out bursty and short-term data transmissions. If MIN is greater than {MAX_INPUT}, the response to the request is undefined. The four possible values for MIN and TIME and their interactions are described below.

 Case A: MIN > 0, TIME > 0
In this case TIME serves as an inter-byte timer and is activated after the first byte is received. Since it is an inter-byte timer, it is reset after a byte is received. The interaction between MIN and TIME is as follows. As soon as one byte is received, the inter-byte timer is started. If MIN bytes are received before the inter-byte timer expires (remember that the timer is reset upon receipt of each byte), the read is satisfied. If the timer expires before MIN bytes are received, the characters received to that point are returned to the user. Note that if TIME expires at least one byte is returned because the timer would not have been enabled unless a byte was received. In this case (MIN > 0, TIME > 0) the read blocks until the MIN and TIME mechanisms are activated by the receipt of the first byte, or a signal is received. If the data is in the buffer at the time of the read(), the result will be as if the data has been received immediately after the read().
 Case B: MIN > 0, TIME = 0
In this case, since the value of TIME is zero, the timer plays no role and only MIN is significant. A pending read is not satisfied until MIN bytes are received (that is, the pending read blocks until MIN bytes are received), or a signal is received. A program that uses this case to read record-based terminal I/O may block indefinitely in the read operation.
 Case C: MIN = 0, TIME > 0
In this case, since MIN = 0, TIME no longer represents an inter-byte timer. It now serves as a read timer that is activated as soon as the read() function is processed. A read is satisfied as soon as a single byte is received or the read timer expires. Note that in this case if the timer expires, no bytes are returned. If the timer does not expire, the only way the read can be satisfied is if a byte is received. In this case the read will not block indefinitely waiting for a byte; if no byte is received within TIME*0.1 seconds after the read is initiated, the read() returns a value of zero, having read no data. If the data is in the buffer at the time of the read(), the timer is started as if the data has been received immediately after the read().
 Case D: MIN = 0, TIME = 0
The minimum of either the number of bytes requested or the number of bytes currently available is returned without waiting for more bytes to be input. If no characters are available, read() returns a value of zero, having read no data.

 Writing Data and Output Processing

When a process writes one or more bytes to a terminal device file, they are processed according to the c_oflag field (see Output Modes ). The implementation may provide a buffering mechanism; as such, when a call to write() completes, all of the bytes written have been scheduled for transmission to the device, but the transmission will not necessarily have completed. See write() for the effects of O_NONBLOCK on write().

 Special Characters

Certain characters have special functions on input or output or both. These functions are summarised as follows:

INTR
Special character on input, which is recognised if the ISIG flag is set. Generates a SIGINT signal which is sent to all processes in the foreground process group for which the terminal is the controlling terminal. If ISIG is set, the INTR character is discarded when processed.
QUIT
Special character on input, which is recognised if the ISIG flag is set. Generates a SIGQUIT signal which is sent to all processes in the foreground process group for which the terminal is the controlling terminal. If ISIG is set, the QUIT character is discarded when processed.
ERASE
Special character on input, which is recognised if the ICANON flag is set. Erases the last character in the current line; see Canonical Mode Input Processing . It will not erase beyond the start of a line, as delimited by an NL, EOF or EOL character. If ICANON is set, the ERASE character is discarded when processed.
KILL
Special character on input, which is recognised if the ICANON flag is set. Deletes the entire line, as delimited by an NL, EOF or EOL character. If ICANON is set, the KILL character is discarded when processed.
EOF
Special character on input, which is recognised if the ICANON flag is set. When received, all the bytes waiting to be read are immediately passed to the process without waiting for a newline, and the EOF is discarded. Thus, if there are no bytes waiting (that is, the EOF occurred at the beginning of a line), a byte count of zero is returned from the read(), representing an end-of-file indication. If ICANON is set, the EOF character is discarded when processed.
NL
Special character on input, which is recognised if the ICANON flag is set. It is the line delimiter newline. It cannot be changed.
EOL
Special character on input, which is recognised if the ICANON flag is set. It is an additional line delimiter, like NL.
SUSP
If the ISIG flag is set, receipt of the SUSP character causes a SIGTSTP signal to be sent to all processes in the foreground process group for which the terminal is the controlling terminal, and the SUSP character is discarded when processed.
STOP
Special character on both input and output, which is recognised if the IXON (output control) or IXOFF (input control) flag is set. Can be used to suspend output temporarily. It is useful with CRT terminals to prevent output from disappearing before it can be read. If IXON is set, the STOP character is discarded when processed.
START
Special character on both input and output, which is recognised if the IXON (output control) or IXOFF (input control) flag is set. Can be used to resume output that has been suspended by a STOP character. If IXON is set, the START character is discarded when processed.
CR
Special character on input, which is recognised if the ICANON flag is set; it is the carriage-return character. When ICANON and ICRNL are set and IGNCR is not set, this character is translated into an NL, and has the same effect as an NL character.

The NL and CR characters cannot be changed. It is implementation-dependent whether the START and STOP characters can be changed. The values for INTR, QUIT, ERASE, KILL, EOF, EOL and SUSP are changeable to suit individual tastes. Special character functions associated with changeable special control characters can be disabled individually.

If two or more special characters have the same value, the function performed when that character is received is undefined.

A special character is recognised not only by its value, but also by its context; for example, an implementation may support multi-byte sequences that have a meaning different from the meaning of the bytes when considered individually. Implementations may also support additional single-byte functions. These implementation-dependent multi-byte or single-byte functions are recognised only if the IEXTEN flag is set; otherwise, data is received without interpretation, except as required to recognise the special characters defined in this section.

If IEXTEN is set, the ERASE, KILL and EOF characters can be escaped by a preceding \ character, in which case no special function occurs.

 Modem Disconnect

If a modem disconnect is detected by the terminal interface for a controlling terminal, and if CLOCAL is not set in the c_cflag field for the terminal (see Control Modes ), the SIGHUP signal is sent to the controlling process for which the terminal is the controlling terminal. Unless other arrangements have been made, this causes the controlling process to terminate (see exit()). Any subsequent read from the terminal device returns the value of zero, indicating end-of-file. (See read().) Thus, processes that read a terminal file and test for end-of-file can terminate appropriately after a disconnect. If the EIO condition as specified in read() also exists, it is unspecified whether on EOF condition or the [EIO] is returned. Any subsequent write() to the terminal device returns -1, with errno set to [EIO], until the device is closed.

 Closing a Terminal Device File

The last process to close a terminal device file causes any output to be sent to the device and any input to be discarded. If HUPCL is set in the control modes and the communications port supports a disconnect function, the terminal device will perform a disconnect.

 Parameters that Can be Set

 The termios Structure

Routines that need to control certain terminal I/O characteristics do so by using the termios structure as defined in the header <termios.h>. The members of this structure include (but are not limited to):
Member Type Array Size Member Name Description
tcflag_t   c_iflag Input modes.
tcflag_t   c_oflag Output modes.
tcflag_t   c_cflag Control modes.
tcflag_t   c_lflag Local modes.
cc_t NCCS c_cc[] Control characters.

The types tcflag_t and cc_t are defined in the header <termios.h>. They are unsigned integral types.

 Input Modes

Values of the c_iflag field describe the basic terminal input control, and are composed of the bitwise inclusive OR of the masks shown, which will be bitwise distinct. The mask name symbols in this table are defined in <termios.h>:

Mask Name Description
BRKINT Signal interrupt on break.
ICRNL Map CR to NL on input.
IGNBRK Ignore break condition.
IGNCR Ignore CR.
IGNPAR Ignore characters with parity errors.
INLCR Map NL to CR on input.
INPCK Enable input parity check.
ISTRIP Strip character.
IUCLC Map upper case to lower case on input. (LEGACY)
IXANY Enable any character to restart output.
IXOFF Enable start/stop input control.
IXON Enable start/stop output control.
PARMRK Mark parity errors.

In the context of asynchronous serial data transmission, a break condition is defined as a sequence of zero-valued bits that continues for more than the time to send one byte. The entire sequence of zero-valued bits is interpreted as a single break condition, even if it continues for a time equivalent to more than one byte. In contexts other than asynchronous serial data transmission, the definition of a break condition is implementation-dependent.

If IGNBRK is set, a break condition detected on input is ignored that is, not put on the input queue and therefore not read by any process. If IGNBRK is not set and BRKINT is set, the break condition will flush the input and output queues, and if the terminal is the controlling terminal of a foreground process group, the break condition will generate a single SIGINT signal to that foreground process group. If neither IGNBRK nor BRKINT is set, a break condition is read as a single 0x00, or if PARMRK is set, as 0xff 0x00 0x00.

If IGNPAR is set, a byte with a framing or parity error (other than break) is ignored.

If PARMRK is set, and IGNPAR is not set, a byte with a framing or parity error (other than break) is given to the application as the three-byte sequence 0xff 0x00 X, where 0xff 0x00 is a two-byte flag preceding each sequence and X is the data of the byte received in error. To avoid ambiguity in this case, if ISTRIP is not set, a valid byte of 0xff is given to the application as 0xff 0xff. If neither PARMRK nor IGNPAR is set, a framing or parity error (other than break) is given to the application as a single byte 0x00.

If INPCK is set, input parity checking is enabled. If INPCK is not set, input parity checking is disabled, allowing output parity generation without input parity errors. Note that whether input parity checking is enabled or disabled is independent of whether parity detection is enabled or disabled (see Control Modes ). If parity detection is enabled but input parity checking is disabled, the hardware to which the terminal is connected will recognise the parity bit but the terminal special file will not check whether or not this bit is correctly set.

If ISTRIP is set, valid input bytes are first stripped to seven bits, otherwise all eight bits are processed.

If INLCR is set, a received NL character is translated into a CR character. If IGNCR is set, a received CR character is ignored (not read). If IGNCR is not set and ICRNL is set, a received CR character is translated into an NL character.

If IUCLC is set, upper- to lower-case mappings are performed on the received character. In locales other than the POSIX locale, the mapping is unspecified. (LEGACY)

If IXANY is set, any input character will restart output that has been suspended.

If IXON is set, start/stop output control is enabled. A received STOP character suspends output and a received START character restarts output. When IXON is set, START and STOP characters are not read, but merely perform flow control functions. When IXON is not set, the START and STOP characters are read.

If IXOFF is set, start/stop input control is enabled. The system transmits STOP characters, which are intended to cause the terminal device to stop transmitting data, as needed to prevent the input queue from overflowing and causing undefined behaviour, and transmits START characters, which are intended to cause the terminal device to resume transmitting data, as soon as the device can continue transmitting data without risk of overflowing the input queue. The precise conditions under which STOP and START characters are transmitted are implementation-dependent.

The initial input control value after open() is implementation-dependent.

 Output Modes

The c_oflag field specifies the terminal interface's treatment of output, and is composed of the bitwise inclusive OR of the masks shown, which will be bitwise distinct. The mask name symbols in this table are defined in <termios.h>:

Mask Name Description
OPOST Perform output processing.
OLCUC Map lower case to upper on output. (LEGACY)
ONLCR Map NL to CR-NL on output.
OCRNL Map CR to NL on output.
ONOCR No CR output at column 0.
ONLRET NL performs CR function.
OFILL Use fill characters for delay.
OFDEL Fill is DEL, else NUL.
NLDLY Select newline delays:
NL0 Newline character type 0
NL1 Newline character type 1.
CRDLY Select carriage-return delays:
CR0 Carriage-return delay type 0
CR1 Carriage-return delay type 1
CR2 Carriage-return delay type 2
CR3 Carriage-return delay type 3.
TABDLY Select horizontal-tab delays:
TAB0 Horizontal-tab delay type 0
TAB1 Horizontal-tab delay type 1
TAB2 Horizontal-tab delay type 2.
TAB3 Expand tabs to spaces.
BSDLY Select backspace delays:
BS0 Backspace-delay type 0
BS1 Backspace-delay type 1.
VTDLY Select vertical-tab delays:
VT0 Vertical-tab delay type 0
VT1 Vertical-tab delay type 1.
FFDLY Select form-feed delays:
FF0 Form-feed delay type 0
FF1 Form-feed delay type 1.

If OPOST is set, output data is post-processed as described below, so that lines of text are modified to appear appropriately on the terminal device; otherwise, characters are transmitted without change.

If OLCUC is set, lower- to upper-case mappings are performed on the characters before they are transmitted. In locales other than the POSIX locale, the mapping is unspecified. (LEGACY)

If ONLCR is set, the NL character is transmitted as the CR-NL character pair. If OCRNL is set, the CR character is transmitted as the NL character. If ONOCR is set, no CR character is transmitted when at column 0 (first position). If ONLRET is set, the NL character is assumed to do the carriage-return function; the column pointer will be set to 0 and the delays specified for CR will be used. Otherwise the NL character is assumed to do just the line-feed function; the column pointer will remain unchanged. The column pointer is also set to 0 if the CR character is actually transmitted.

The delay bits specify how long transmission stops to allow for mechanical or other movement when certain characters are sent to the terminal. In all cases a value of 0 indicates no delay. If OFILL is set, fill characters will be transmitted for delay instead of a timed delay. This is useful for high baud rate terminals which need only a minimal delay. If OFDEL is set, the fill character is DEL, otherwise NUL.

If a form-feed or vertical-tab delay is specified, it lasts for about 2 seconds.

New-line delay lasts about 0.10 seconds. If ONLRET is set, the carriage-return delays are used instead of the newline delays. If OFILL is set, two fill characters will be transmitted.

Carriage-return delay type 1 is dependent on the current column position, type 2 is about 0.10 seconds, and type 3 is about 0.15 seconds. If OFILL is set, delay type 1 transmits two fill characters, and type 2, four fill characters.

Horizontal-tab delay type 1 is dependent on the current column position. Type 2 is about 0.10 seconds. Type 3 specifies that tabs are to be expanded into spaces. If OFILL is set, two fill characters will be transmitted for any delay.

Backspace delay lasts about 0.05 seconds. If OFILL is set, one fill character will be transmitted.

The actual delays depend on line speed and system load.

The initial output control value after open() is implementation-dependent.

 Control Modes

The c_cflag field describes the hardware control of the terminal, and is composed of the bitwise inclusive OR of the masks shown, which will be bitwise distinct. The mask name symbols in this table are defined in <termios.h>; not all values specified are required to be supported by the underlying hardware:
Mask Name Description
CLOCAL Ignore modem status lines.
CREAD Enable receiver.
CSIZE Number of bits transmitted or received per byte:
CS5 5 bits
CS6 6 bits
CS7 7 bits
CS8 8 bits.
CSTOPB Send two stop bits, else one.
HUPCL Hang up on last close.
PARENB Parity enable.
PARODD Odd parity, else even.

In addition, the input and output baud rates are stored in the termios structure. The following values are supported:

Name Description Name Description
B0 Hang up B600 600 baud
B50 50 baud B1200 1200 baud
B75 75 baud B1800 1800 baud
B110 110 baud B2400 2400 baud
B134 134.5 baud B4800 4800 baud
B150 150 baud B9600 9600 baud
B200 200 baud B19200 19200 baud
B300 300 baud B38400 38400 baud

The following interfaces are provided for getting and setting the values of the input and output baud rates in the termios structure: cfgetispeed(), cfgetospeed(), cfsetispeed() and cfsetospeed(). The effects on the terminal device do not become effective and not all errors are detected until the tcsetattr() function is successfully called.

The CSIZE bits specify the number of transmitted or received bits per byte. If ISTRIP is not set, the value of all the other bits is unspecified. If ISTRIP is set, the value of all but the 7 low-order bits is zero, but the value of any other bits beyond CSIZE is unspecified when read. CSIZE does not include the parity bit, if any. If CSTOPB is set, two stop bits are used, otherwise one stop bit. For example, at 110 baud, two stop bits are normally used.

If CREAD is set, the receiver is enabled. Otherwise, no characters will be received.

If PARENB is set, parity generation and detection is enabled and a parity bit is added to each byte. If parity is enabled, PARODD specifies odd parity if set, otherwise even parity is used.

If HUPCL is set, the modem control lines for the port are lowered when the last process with the port open closes the port or the process terminates. The modem connection is broken.

If CLOCAL is set, a connection does not depend on the state of the modem status lines. If CLOCAL is clear, the modem status lines are monitored.

Under normal circumstances, a call to the open() function waits for the modem connection to complete. However, if the O_NONBLOCK flag is set (see open()) or if CLOCAL has been set, the open() function returns immediately without waiting for the connection.

If the object for which the control modes are set is not an asynchronous serial connection, some of the modes may be ignored; for example, if an attempt is made to set the baud rate on a network connection to a terminal on another host, the baud rate may or may not be set on the connection between that terminal and the machine to which it is directly connected.

The initial hardware control value after open() is implementation-dependent.

 Local Modes

The c_lflag field of the argument structure is used to control various functions. It is composed of the bitwise inclusive OR of the masks shown, which will be bitwise distinct. The mask name symbols in this table are defined in <termios.h>; not all values specified are required to be supported by the underlying hardware:

Mask Name Description
ECHO Enable echo.
ECHOE Echo ERASE as an error correcting backspace.
ECHOK Echo KILL.
ECHONL Echo <newline>.
ICANON Canonical input (erase and kill processing).
IEXTEN Enable extended (implementation-dependent) functions.
ISIG Enable signals.
NOFLSH Disable flush after interrupt, quit or suspend.
TOSTOP Send SIGTTOU for background output.
XCASE Canonical upper/lower presentation. (LEGACY)

If ECHO is set, input characters are echoed back to the terminal. If ECHO is clear, input characters are not echoed.

If ECHOE and ICANON are set, the ERASE character causes the terminal to erase, if possible, the last character in the current line from the display. If there were no character to erase, an implementation might echo an indication that this was the case, or do nothing.

If ECHOK and ICANON are set, the KILL character causes the terminal to erase the line from the display or echoes the newline character after the KILL character.

If ECHONL and ICANON are set, the newline character is echoed even if ECHO is not set.

If ICANON is set, canonical processing is enabled. This enables the erase and kill edit functions, and the assembly of input characters into lines delimited by NL, EOF and EOL, as described in Canonical Mode Input Processing .

If ICANON is not set, read requests are satisfied directly from the input queue. A read is not satisfied until at least MIN bytes have been received or the timeout value TIME expired between bytes. The time value represents tenths of a second. See Non-canonical Mode Input Processing for more details.

If IEXTEN is set, implementation-dependent functions are recognised from the input data. It is implementation-dependent how IEXTEN being set interacts with ICANON, ISIG, IXON or IXOFF. If IEXTEN is not set, implementation-dependent functions are not recognised and the corresponding input characters are processed as described for ICANON, ISIG, IXON and IXOFF.

If ISIG is set, each input character is checked against the special control characters INTR, QUIT and SUSP. If an input character matches one of these control characters, the function associated with that character is performed. If ISIG is not set, no checking is done. Thus these special input functions are possible only if ISIG is set.

If NOFLSH is set, the normal flush of the input and output queues associated with the INTR, QUIT and SUSP characters is not done.

If TOSTOP is set, the signal SIGTTOU is sent to the process group of a process that tries to write to its controlling terminal if it is not in the foreground process group for that terminal. This signal, by default, stops the members of the process group. Otherwise, the output generated by that process is output to the current output stream. Processes that are blocking or ignoring SIGTTOU signals are excepted and allowed to produce output, and the SIGTTOU signal is not sent.

If XCASE is set, canonical lower and canonical upper presentation are performed. In locales other than the POSIX locale, the effect is unspecified. (LEGACY)

The initial local control value after open() is implementation-dependent.

 Special Control Characters

The special control characters values are defined by the array c_cc. The subscript name and description for each element in both canonical and non-canonical modes are as follows:

Subscript Usage  
Canonical Non-canonical  
Mode Mode Description
VEOF   EOF character
VEOL   EOL character
VERASE   ERASE character
VINTR VINTR INTR character
VKILL   KILL character
  VMIN MIN value
VQUIT VQUIT QUIT character
VSUSP VSUSP SUSP character
  VTIME TIME value
VSTART VSTART START character
VSTOP VSTOP STOP character

The subscript values are unique, except that the VMIN and VTIME subscripts may have the same values as the VEOF and VEOL subscripts, respectively.

The number of elements in the c_cc array, NCCS, is unspecified.

Implementations that do not support changing the START and STOP characters may ignore the character values in the c_cc array indexed by the VSTART and VSTOP subscripts when tcsetattr() is called, but will return the value in use when tcgetattr() is called.

The initial values of all control characters are implementation-dependent.

If the value of one of the changeable special control characters (see Special Characters ) is {_POSIX_VDISABLE}, that function is disabled; that is, no input data will be recognised as the disabled special character. If ICANON is not set, the value of {_POSIX_VDISABLE} has no special meaning for the VMIN and VTIME entries of the c_cc array.


UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]