|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| INTR | Special character on input and is recognized if the ISIG flag (see the Local Modes section) is enabled. 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 and is recognized if the ISIG flag is enabled. 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 and is recognized if the ICANON flag is set. Erases the last character in the current line; see Canonical Mode Input Processing. It does 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 and is recognized if the ICANON flag is set. Deletes the entire line, as delimited by a NL, EOF, or EOL character. If ICANON is set, the KILL character is discarded when processed. |
| EOF | Special character on input and is recognized 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 and is recognized if the ICANON flag is set. It is the line delimiter \n. |
| EOL | Special character on input and is recognized if the ICANON flag is set. Is an additional line delimiter, like NL. |
| SUSP | If the ISIG flag is enabled, 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 and is recognized if the IXON (output control) or IXOFF (input control) flag is set. Can be used to temporarily suspend output. It is useful with fast 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 and is recognized 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 and is recognized if the ICANON flag is set; it is the \r, as denoted in the C Standard {2}. When ICANON and ICRNL are set and IGNCR is not set, this character is translated into a NL, and has the same effect as a NL character. |
The following special characters are extensions defined by this system and are not a part of -p1003.1 termios.
| EOL2 | Secondary EOL character. Same function as EOL. |
| WERASE | |
| Special character on input and is recognized if the ICANON flag is set. Erases the last word in the current line according to one of two algorithms. If the ALTWERASE flag is not set, first any preceding whitespace is erased, and then the maximal sequence of non-whitespace characters. If ALTWERASE is set, first any preceding whitespace is erased, and then the maximal sequence of alphabetic/underscores or non alphabetic/underscores. As a special case in this second algorithm, the first previous non-whitespace character is skipped in determining whether the preceding word is a sequence of alphabetic/underscores. This sounds confusing but turns out to be quite practical. | |
| REPRINT | |
| Special character on input and is recognized if the ICANON flag is set. Causes the current input edit line to be retyped. | |
| DSUSP | Has similar actions to the SUSP character, except that the SIGTSTP signal is delivered when one of the processes in the foreground process group issues a read to the controlling terminal. |
| LNEXT | Special character on input and is recognized if the IEXTEN flag is set. Receipt of this character causes the next character to be taken literally. |
| DISCARD | |
| Special character on input and is recognized if the IEXTEN flag is set. Receipt of this character toggles the flushing of terminal output. | |
| STATUS | |
| Special character on input and is recognized if the ICANON flag is set. Receipt of this character causes a SIGINFO signal to be sent to the foreground process group of the terminal. Also, if the NOKERNINFO flag is not set, it causes the kernel to write a status message to the terminal that displays the current load average, the name of the command in the foreground, its process ID, the symbolic wait channel, the number of user and system seconds used, the percentage of cpu the process is getting, and the resident set size of the process. | |
The NL and CR characters cannot be changed. The values for all the remaining characters can be set and are described later in the document under Special Control Characters.
Special character functions associated with changeable special control characters can be disabled individually by setting their value to {_POSIX_VDISABLE}; see Special Control Characters.
If two or more special characters have the same value, the function performed when that character is received is undefined.
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, the SIGHUP signal is sent to the controlling process associated with the terminal. Unless other arrangements have been made, this causes the controlling process to terminate. Any subsequent call to the read function returns the value zero, indicating end of file. Thus, processes that read a terminal file and test for end-of-file can terminate appropriately after a disconnect. Any subsequent write to the terminal device returns -1, with errno set to EIO, until the device is closed.
The last process to close a terminal device file causes any output to be sent to the device and any input to be discarded. Then, if HUPCL is set in the control modes, and the communications port supports a disconnect function, the terminal device performs a disconnect.
Routines that need to control certain terminal I/O characteristics do so by using the termios structure as defined in the header
.In termios.h . This structure contains minimally four scalar elements of bit flags and one array of special characters. The scalar flag elements are named: c_iflag, c_oflag, c_cflag, and c_lflag. The character array is named c_cc, and its maximum index is NCCS.
Values of the c_iflag field describe the basic terminal input control, and are composed of following masks:
IGNBRK /* ignore BREAK condition */ BRKINT /* map BREAK to SIGINTR */ IGNPAR /* ignore (discard) parity errors */ PARMRK /* mark parity and framing errors */ INPCK /* enable checking of parity errors */ ISTRIP /* strip 8th bit off chars */ INLCR /* map NL into CR */ IGNCR /* ignore CR */ ICRNL /* map CR to NL (ala CRMOD) */ IXON /* enable output flow control */ IXOFF /* enable input flow control */ IXANY /* any char will restart after stop */ IMAXBEL /* ring bell on input queue full */ 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 defined.
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 flushes the input and output queues and if the terminal is the controlling terminal of a foreground process group, the break condition generates a single SIGINT signal to that foreground process group. If neither IGNBRK nor BRKINT is set, a break condition is read as a single \0, or if PARMRK is set, as \377, \0, \0.
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-character sequence \377, \0, X, where \377, \0 is a two-character flag preceding each sequence and X is the data of the character received in error. To avoid ambiguity in this case, if ISTRIP is not set, a valid character of \377 is given to the application as \377, \377. If neither PARMRK nor IGNPAR is set, a framing or parity error (other than break) is given to the application as a single character \0.
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 recognizes the parity bit, but the terminal special file does not check whether this bit is set correctly or not.
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 a NL character.
If IXON is set, start/stop output control is enabled. A received STOP character suspends output and a received START character restarts output. If IXANY is also set, then any character may restart 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 shall transmit one or more 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 the undefined behavior described in Input Processing and Reading Data, and shall transmit one or more 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 defined.
If IMAXBEL is set and the input queue is full, subsequent input shall cause an ASCII BEL character to be transmitted to the output queue.
The initial input control value after open is implementation defined.
Values of the c_oflag field describe the basic terminal output control, and are composed of the following masks:
OPOST /* enable following output processing */ ONLCR /* map NL to CR-NL (ala CRMOD) */ OCRNL /* map CR to NL */ OXTABS /* expand tabs to spaces */ ONOEOT /* discard EOT s ^D on output) */ ONOCR /* do not transmit CRs on column 0 */ ONLRET /* on the terminal NL performs the CR function */ If OPOST is set, the remaining flag masks are interpreted as follows; otherwise characters are transmitted without change.
If ONLCR is set, newlines are translated to carriage return, linefeeds.
If OCRNL is set, carriage returns are translated to newlines.
If OXTABS is set, tabs are expanded to the appropriate number of spaces (assuming 8 column tab stops).
If ONOEOT is set, ASCII EOT s are discarded on output.
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.
Values of the c_cflag field describe the basic terminal hardware control, and are composed of the following masks. Not all values specified are supported by all hardware.
CSIZE /* character size mask */ CS5 /* 5 bits (pseudo) */ CS6 /* 6 bits */ CS7 /* 7 bits */ CS8 /* 8 bits */ CSTOPB /* send 2 stop bits */ CREAD /* enable receiver */ PARENB /* parity enable */ PARODD /* odd parity, else even */ HUPCL /* hang up on last close */ CLOCAL /* ignore modem status lines */ CCTS_OFLOW /* CTS flow control of output */ CRTSCTS /* same as CCTS_OFLOW */ CRTS_IFLOW /* RTS flow control of input */ MDMBUF /* flow control output via Carrier */ The CSIZE bits specify the byte size in bits for both transmission and reception. The c_cflag is masked with CSIZE and compared with the values CS5, CS6, CS7, or CS8. This size 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 character is received. Not all hardware supports this bit. In fact, this flag is pretty silly and if it were not part of the termios specification it would be omitted.
If PARENB is set, parity generation and detection are enabled and a parity bit is added to each character. 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 or if CLOCAL has been set, the open function returns immediately without waiting for the connection.
The CCTS_OFLOW ( CRTSCTS) flag is currently unused.
If MDMBUF is set then output flow control is controlled by the state of Carrier Detect.
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 it is directly connected to.
Values of the c_lflag field describe the control of various functions, and are composed of the following masks.
ECHOKE /* visual erase for line kill */ ECHOE /* visually erase chars */ ECHO /* enable echoing */ ECHONL /* echo NL even if ECHO is off */ ECHOPRT /* visual erase mode for hardcopy */ ECHOCTL /* echo control chars as ^(Char) */ ISIG /* enable signals INTR, QUIT, [D]SUSP */ ICANON /* canonicalize input lines */ ALTWERASE /* use alternate WERASE algorithm */ IEXTEN /* enable DISCARD and LNEXT */ EXTPROC /* external processing */ TOSTOP /* stop background jobs from output */ FLUSHO /* output being flushed (state) */ NOKERNINFO /* no kernel output from VSTATUS */ PENDIN /* XXX retype pending input (state) */ NOFLSH /* dont flush after interrupt */ If ECHO is set, input characters are echoed back to the terminal. If ECHO is not set, input characters are not echoed.
If ECHOE and ICANON are set, the ERASE character causes the terminal to erase the last character in the current line from the display, if possible. If there is no character to erase, an implementation may echo an indication that this was the case or do nothing.
If ECHOK and ICANON are set, the KILL character causes the current line to be discarded and the system echoes the \n character after the KILL character.
If ECHOKE and ICANON are set, the KILL character causes the current line to be discarded and the system causes the terminal to erase the line from the display.
If ECHOPRT and ICANON are set, the system assumes that the display is a printing device and prints a backslash and the erased characters when processing ERASE characters, followed by a forward slash.
If ECHOCTL is set, the system echoes control characters in a visible fashion using a caret followed by the control character.
If ALTWERASE is set, the system uses an alternative algorithm for determining what constitutes a word when processing WERASE characters (see WERASE).
If ECHONL and ICANON are set, the \n character echoes 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 seconds. See Noncanonical Mode Input Processing for more details.
If ISIG is set, each input character is checked against the special control characters INTR, QUIT, and SUSP (job control only). 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 IEXTEN is set, implementation-defined functions are recognized from the input data. How IEXTEN being set interacts with ICANON, ISIG, IXON, or IXOFF is implementation defined. If IEXTEN is not set, then implementation-defined functions are not recognized, and the corresponding input characters are not processed as described for ICANON, ISIG, IXON, and IXOFF.
If NOFLSH is set, the normal flush of the input and output queues associated with the INTR, QUIT, and SUSP characters are not be 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 NOKERNINFO is set, the kernel does not produce a status message when processing STATUS characters (see STATUS).
The special control characters values are defined by the array c_cc. This table lists the array index, the corresponding special character, and the system default value. For an accurate list of the system defaults, consult the header file
.In sys/ttydefaults.h .
Index Name Special Character Default Value
VEOF EOF ^D
VEOL EOL _POSIX_VDISABLE
VEOL2 EOL2 _POSIX_VDISABLE
VERASE ERASE ^?\177
VWERASE WERASE ^W
VKILL KILL ^U
VREPRINT REPRINT ^R
VINTR INTR ^C
VQUIT QUIT ^\\\34
VSUSP SUSP ^Z
VDSUSP DSUSP ^Y
VSTART START ^Q
VSTOP STOP ^S
VLNEXT LNEXT ^V
VDISCARD DISCARD ^O
VMIN --- 1
VTIME --- 0
VSTATUS STATUS ^TIf 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 is recognized 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.
The initial values of the flags and control characters after open is set according to the values in the header
.In sys/ttydefaults.h .
| May 13, 2008 | TERMIOS (4) |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.