DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

termio(M)


termio -- general terminal interface

Syntax

#include <sys/termio.h>

#include <sys/winsize.h>

Description

All asynchronous communications ports use the same general interface, no matter what hardware is involved. The remainder of this manual page discusses the common features of this interface. Please refer to termios(M) for details of the POSIX.1 termios structure.

When a terminal file is opened, it normally causes the process to wait until a connection is established. In practice, users' programs seldom open these files; they are opened by getty(M) and become a user's standard input, output, and error files. (To do this, getty opens the terminal for read/write access, then duplicates this I/O stream twice.) The very first terminal file opened by the process group leader of a terminal file not already associated with a process group becomes the ``control terminal'' for that process group. The control terminal plays a special role in handling quit and interrupt signals, as discussed below. The control terminal is inherited by a child process during a fork(S). A process can break this association by changing its process group using setpgrp(S).

A terminal associated with one of these files ordinarily operates in full duplex mode. Characters can be entered at any time, even while output is occurring, and are only lost when the system's character input buffers become completely full, which is rare, or when the user has accumulated the maximum allowed number of input characters that have not yet been read by some program. Currently, this limit is 256 characters. When the input limit is reached, all the saved characters are thrown away without notice.

Normally, terminal input is processed in units of lines. A line is delimited by a newline (ASCII LF) character, an end-of-file (ASCII EOT) character, or an end-of-line (ASCII EOL) character. This means that a program attempting to read will be suspended until an entire line has been entered. Also, no matter how many characters are requested in the read call, one line will be returned at most. It is not, however, necessary to read a whole line at once; any number of characters, even one, may be requested in a read without losing information.

Erase and kill processing is normally performed during input. By default, a <Ctrl>h or <Bksp> erases the last character typed, but it will not erase beyond the beginning of the line. By default, a <Ctrl>u kills (deletes) the entire input line, and optionally outputs a newline character. Both these characters operate on a keystroke basis, independent of any backspacing or tabbing that may have been done. Both the erase and kill characters may be entered literally by preceding them with the escape character (\). In this case, the escape character is not read. The erase and kill characters may be changed (see stty(C)).

See ``Special control characters'' for more information about control characters.

When the carrier signal from the dataset drops, a ``hangup'' signal is sent to all processes that have this terminal as the control terminal. Unless other arrangements have been made, this signal causes the processes to terminate. If the hangup signal is ignored, any subsequent read returns with an end-of-file indication. Thus, programs that read a terminal and test for an end-of-file can terminate appropriately when hung up on.

When one or more characters are written, they are transmitted to the terminal as soon as the previously typed characters have been entered. Input characters are echoed by putting them in the output queue as they arrive. If a process produces characters more rapidly than they can be typed, it will be suspended when its output queue exceeds a given limit. When the queue has drained down to the given threshold, the program is resumed.

ioctl commands

Several ioctl(S) system calls apply to terminal files. The primary calls use the termio structure, defined in the file /usr/include/sys/termio.h:
   #define	NCC	8
   

struct termio { unsigned short c_iflag; /* input modes */ unsigned short c_oflag; /* output modes */ unsigned short c_cflag; /* control modes */ unsigned short c_lflag; /* line discipline modes */ char c_line; /* line discipline */ unsigned char c_cc[NCC]; /* control chars */ };

POSIX.1 defined the termios structure which extended the capabilities available with termio. See termios(M) for a definition of the termios structure in the current and previous releases.

Primary ioctl system calls have one of the following forms:

ioctl (fildes, command, arg)
struct termio *arg;

ioctl (fildes, command, arg)
struct termios *arg;

Commands using this form are:


TCGETA
Get the parameters associated with the terminal and store them in the termio structure referenced by arg.

TCSETA
Set the parameters associated with the terminal from the termio structure referenced by arg. The change is immediate.

TCGETS
Get the parameters associated with the terminal and store them in the termios structure referenced by arg.

TCSETS
Set the parameters associated with the terminal from the termios structure referenced by arg. The change is immediate.

TCSETSW
Set the parameters associated with the terminal from the termios structure referenced by arg. The change occurs after all characters cued for output have been transmitted. This form should be used when changing parameters that affect output.

TCSETSF
Set the parameters associated with the terminal from the termios structure referenced by arg. The change occurs after all characters cued for output have been transmitted; all characters cued for input are discarded and the change occurs.

TCSETAW
Wait for the output to drain before setting the new parameters. This form should be used when changing parameters that will affect output.

TCSETAF
Wait for the output to drain, then flush the input queue and set the new parameters.

Additional ioctl calls have the form:

ioctl (fildes, command, arg)
int arg;

Commands using this form are:


TCSBRK
Wait for the output to drain. If arg is 0, then send a break (zero bits for 0.25 seconds).

TCXONC
Start/stop control. If arg is 0, suspend output; if 1, restart suspended output; if 2, block; if 3, unblock.

TCFLSH
If arg is 0, flush the input queue; if 1, flush the output queue; if 2, flush both the input and output queues.

Special control characters

The special control characters (used to interrupt processes, erase characters, and switch jobs) are defined by the array c_cc field of the termio structure. The positions and corresponding index names of the control characters in the c_cc array are shown in the following table:

Position Index name Comment
0 VINTR
1 VQUIT
2 VERASE
3 VKILL
4 VEOF/VMIN
5 VEOL/VTIME
6 VEOL2
7 VSWTCH
10 VSUSP termios and SVID3 termio only
11 VSTART termios and SVID3 termio only
12 VSTOP termios and SVID3 termio only
13 VDISCARD SVID3 termio only
14 VWERASE SVID3 termio only
15 VLNEXT SVID3 termio only
16 VDSUSP SVID3 termio only
17 VREPRINT SVID3 termio only

 +---------+------------+-------------------------------+
 |Position | Index name | Comment                       |
 +---------+------------+-------------------------------+
 |0        | VINTR      |                               |
 +---------+------------+-------------------------------+
 |1        | VQUIT      |                               |
 +---------+------------+-------------------------------+
 |2        | VERASE     |                               |
 +---------+------------+-------------------------------+
 |3        | VKILL      |                               |
 +---------+------------+-------------------------------+
 |4        | VEOF/VMIN  |                               |
 +---------+------------+-------------------------------+
 |5        | VEOL/VTIME |                               |
 +---------+------------+-------------------------------+
 |6        | VEOL2      |                               |
 +---------+------------+-------------------------------+
 |7        | VSWTCH     |                               |
 +---------+------------+-------------------------------+
 |10       | VSUSP      | termios and SVID3 termio only |
 +---------+------------+-------------------------------+
 |11       | VSTART     | termios and SVID3 termio only |
 +---------+------------+-------------------------------+
 |12       | VSTOP      | termios and SVID3 termio only |
 +---------+------------+-------------------------------+
 |13       | VDISCARD   | SVID3 termio only             |
 +---------+------------+-------------------------------+
 |14       | VWERASE    | SVID3 termio only             |
 +---------+------------+-------------------------------+
 |15       | VLNEXT     | SVID3 termio only             |
 +---------+------------+-------------------------------+
 |16       | VDSUSP     | SVID3 termio only             |
 +---------+------------+-------------------------------+
 |17       | VREPRINT   | SVID3 termio only             |
 +---------+------------+-------------------------------+

The function and default values of the special control characters are summarized below. Note that the default character value may be overridden by the application being used.

INTR
(CINTR: rubout or ASCII DEL) Generate an interrupt signal which is sent to all processes with the associated control terminal. Normally, each such process is forced to terminate, but arrangements may be made either to ignore the signal or to receive a trap to an agreed-upon location; see signal(S).

QUIT
(CQUIT: <Ctrl>\ or ASCII FS) Generate a quit signal. Its treatment is identical to the interrupt signal except that, unless a receiving process has made other arrangements, it will not only be terminated, but a core image file (core) will be created in the current working directory.

SWTCH
(CSWTCH: <Ctrl>q or ASCII SUB) Used by the shell layers facility, shl(C), to change the current layer to the control layer.

ERASE
(CERASE: <Ctrl>h or ASCII BS) Erase the preceding character. It will not erase beyond the start of a line, as delimited by an NL, EOF, EOL, or EOL2 character.

WERASE
(CWERASE: <Ctrl>w or ASCII ETX) Erase the preceding word. It will not erase beyond the start of a line, as delimited by an NL, EOF, EOL, or EOL2 character. (SVID3 line discipline only.)

KILL
(CKILL: <Ctrl>u or ASCII NAK) Delete the entire line, as delimited by a NL, EOF, or EOL character.

REPRINT
(CRPRNT: <Ctrl>r or ASCII DC2) Reprint all characters that have not previously been read, preceding them with a newline. (SVID3 line discipline only.)

EOF
(CEOF: <Ctrl>d or ASCII EOT) May be used to generate an end-of-file from a terminal. When received, all the characters waiting to be read are immediately passed to the program, without waiting for a newline, and the EOF is discarded. Thus, if there are no characters waiting, which is to say the EOF occurred at the beginning of a line, zero characters will be passed back, which is the standard end-of-file indication.

NL
(ASCII LF) The normal line delimiter; it cannot be changed or escaped.

EOL
(CEOL: ASCII NUL) An additional line delimiter, like NL. It is not normally used.

EOL2
(CEOL2: ASCII NUL) An additional line delimiter, like EOL. It is not normally used.

SUSP
(CSUSP: <Ctrl>z or ASCII SUB) If the ISIG flag is enabled, receipt of the SUSP character causes a SIGTSTP signal to be sent to the current process group. SUSP is discarded after being processed and is set to ASCII NUL by default. If SUSP is set to <Ctrl>z in the Korn shell, for example, it allows the currently executing process in the foreground process group to be temporarily suspended. The SUSP character can only be changed or escaped if the SVID3 line discipline or the termios structure is used (see termios(M)).

DSUSP
(CDSUSP: <Ctrl>y or ASCII EM) Delayed suspend similar to SUSP. The SIGTSTP signal is sent when the process in the foreground process group tries to read DSUSP rather than when the character is typed. If the ISIG flag is enabled, receipt of the SUSP character causes a SIGTSTP signal to be sent to the current process group. (SVID3 line discipline only.)

STOP
(CSTOP: <Ctrl>s or ASCII DC3) Temporarily suspend output. It is useful with CRT terminals to prevent output from disappearing before it can be read. While output is suspended, STOP characters are ignored and not read. The STOP character can only be changed or escaped if the SVID3 line discipline or the termios structure is used (see termios(M)).

START
(CSTART: <Ctrl>q or ASCII DC1) Resume output which has been suspended by a STOP character. While output is not suspended, START characters are ignored and not read. The START character can only be changed or escaped if the SVID3 line discipline or the termios structure is used (see termios(M)).

DISCARD
(CFLUSH: <Ctrl>o or ASCII SI) Discard subsequent output until another DISCARD is entered, more input is received, or the program clears the condition. (SVID3 line discipline only.)

LNEXT
(CLNEXT: <Ctrl>v or ASCII SYN) Ignore the special meaning of the following special character. This stops characters such as QUIT being interpreted. (SVID3 line discipline only.)

The character values for INTR, QUIT, SWTCH, STOP, START, SUSP, DSUSP, ERASE, WERASE, REPRINT, WERASE, KILL, EOF, EOL, and EOL2 can be changed to suit a particular application. The ERASE, KILL, and EOF characters may be escaped by a preceding backslash (\) character, in which case no special function is carried out.

Input modes

The c_iflag field specifies the treatment of input. The initial value of this field is 0 (all bits clear).

The following input mode flags may be set:


IGNBRK
Ignore the break condition (a character framing error with data all zeros). It is not put on the input queue and is therefore not read by any process.

BRKINT
Cause the break condition to generate an interrupt signal (SIGINT) and flush both the input and output queues. If the terminal device is a controlling terminal, SIGINT is sent to all processes in the foreground process group.

IGNPAR
Ignore characters with other framing and parity errors.

PARMRK
If set, read a character with a framing or parity error which is not ignored as the 3-character sequence: ``0377 0 X'', where X is the data of the character received in error. To avoid ambiguity in this case, if ISTRIP is not set, read a valid character of ``0377'' as ``0377 0377''.

If not set, read a framing or parity error which is not ignored as the character NUL (0).


INPCK
If set, input parity checking is enabled.

If not set, disable input parity checking. This allows output parity generation without input parity errors.


ISTRIP
If set, strip valid input characters to 7 bits.

If not set, process all 8 bits.


INLCR
Translate a received NL character into a CR character.

IGNCR
Ignore (do not read) a received CR character.

ICRNL
Translate a received CR character into a NL character.

IUCLC
Translate a received uppercase alphabetic character into the corresponding lowercase character.

IXON
If set, enable start/stop output control. A received STOP character suspends output and a received START character restarts output. If not set, ignore (do not read) all start/stop characters.

IXANY
Cause any input character to restart output which has been suspended.

IXOFF
If set, enable start/stop input control. Transmit START characters when the input queue is nearly empty and STOP characters when nearly full.

IMAXBEL
If set, echo the ASCII BEL character if the input buffer overflows. Any input currently present in the input buffer is not affected. Only subsequent characters on the line are discarded. If IMAXBEL is not set, BEL is not echoed and all characters in the input buffer are discarded if the buffer overflows. (SVID3 line discipline only.)

Output modes

The c_oflag field specifies the treatment of output. The initial value of this field is 0 (all bits clear).

The following output mode flags may be set:


OPOST
If set, output characters are post-processed as indicated by the remaining flags.

If not set, characters are transmitted without change.


OLCUC
Transmit a lowercase alphabetic character as the corresponding uppercase character. This function is often used in conjunction with IUCLC.

ONLCR
Transmit the NL character as the CR NL character pair.

OCRNL
Transmit the CR character as the NL character.

ONOCR
Do not transmit the CR character when it is in column 0 (first position).

ONLRET
If set, use the NL character to perform the carriage return function; the column pointer is set to 0, and the delays specified for CR will be used.

If not set, use the NL character to perform the linefeed function; the column pointer will remain unchanged. Also set the column pointer 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. No delay is implemented if none of the bits has been set. Note that actual delays depend on line speed and system load.

The following delay modes are defined:


OFILL
Transmit fill characters to implement a delay instead of a real timed delay. This is useful for high baud rate terminals which need only a minimal delay.

OFDEL
If set, DEL is the fill character; if not set, it is NUL.

NLDLY
Use to turn off the newline delay bits.

NL1
Select a newline delay of about 0.10 seconds. If ONLRET is set, use carriage return delays instead of newline delays.

CRDLY
Use to turn off the carriage return delay bits.

CR1
Select a carriage return delay dependent on the current column position. If OFILL is set, transmit 2 fill characters.

CR2
Select a carriage return delay of about 0.10 seconds. If OFILL is set, transmit 4 fill characters.

CR3
Select a carriage return delay of about 0.15 seconds.

TABDLY
Use to turn off the horizontal tab delay bits.

TAB1
Select a horizontal tab delay which is dependent on the current column position. If OFILL is set, 2 fill characters will be transmitted for any delay.

TAB2
Select a horizontal tab delay of about 0.10 seconds. If OFILL is set, 2 fill characters will be transmitted for any delay.

TAB3
Specify that tabs are to be expanded into spaces.

XTABS
Equivalent to TAB3. (SVID3 line discipline only.)

BSDLY
Use to turn off the backspace delay bits.

BS1
Select a backspace delay of about 0.05 seconds. If OFILL is set, 1 fill character will be transmitted.

VTDLY
Use to turn off the vertical tab delay bits.

VT1
Select a vertical tab delay of about 2 seconds.

FFDLY
Use to turn off the form feed delay bits.

FF1
Select a form feed delay of about 2 seconds.

Hardware control modes

The c_cflag field describes the hardware control of the terminal. The initial value of this field is B9600, CS8, CREAD, HUPCL.

The following hardware control flags may be set:


CBAUD
Use to turn off the baud rate bits.

B0
Zero baud rate; used to hang up a connection. If B0 is specified, Data Terminal Ready (DTR) will not be asserted. Without DTR, the line is disconnected if it is connected through a modem. For any particular hardware, impossible speed changes are ignored.

B50 B75 B110 B134 B150 B200 B300 B600 B1200

B1800 B2400 B4800 B9600 B19200 EXTA B38400 EXTB
Use to specify serial line speeds.

B57600 B76800 B115200 B230400 B460800 B921600
Use to specify high serial line speeds. These speeds may only be set and read using the cfsetispeed, cfsetospeed, cfgetispeed, and cfgetospeed functions documented on the termios(S) manual page.

CSIZE
Use to turn off the character size bits.

CS5 CS6 CS7 CS8
Use to specify the character size in bits for both transmission and reception. This size does not include the parity bit, if any.

CSTOPB
If set, use 2 stop bits; if not set, use 1 stop bit. For example, at 110 baud, 2 stops bits are required.

CREAD
If set, enable the receiver; if not set, the receiver is disabled and no characters will be received.

PARENB
Enable parity generation and detection, and add a parity bit to each character.

PARODD
If set, select odd parity if PARENB is also set; if not set, select even parity if PARENB is also set.

HUPCL
Disconnect the line when the last process with the line open either closes it or terminates; that is, Data Terminal Ready (DTR) is dropped.

CLOCAL
If set, assume the line to be a local, direct connection with no modem control. Data Terminal Ready (DTR) and Request To Send (RTS) are asserted, but incoming modem signals (Data Carrier Detect DCD and Data Set Ready DSR) are ignored.

If not set, modem control is assumed. DTR and RTS are asserted, but DCD and DSR must also be received before communication can proceed.


LOBLK
If set, block the output of a shell layer when it is not the current layer; if not set, multiplex the output generated by the shell layer onto the current layer.

CTSFLOW
Enable CTS handshaking.

RTSFLOW
Enable RTS handshaking.

CTSFLOW and RTSFLOW correspond to the stty settings ctsflow and rtsflow.

The RS-232 serial interface provides the RTS and CTS signal lines to allow handshaking between Data Terminal Equipment (DTE; devices such as terminals and computers) and Data Circuit terminating Equipment (sometimes referred to as Data Communication Equipment or DCE; almost always a modem). (There are exceptions to these definitions; for example, DCE serial ports and DTE modems exist.) Communication using bidirectional flow control in hardware is more efficient and reliable than using software flow control (XON/XOFF). There is also no problem with sending binary data if hardware flow control is used.

Unidirectional flow control works in the following manner:

In this way, the DCE controls the flow of data from the DTE but not the other way around. The implicit assumption is that the DTE is faster than the DCE. With the high-speed modems now available, bidirectional flow control is used in preference; this avoids the possibility of characters being lost due to the modem causing the input buffer on the serial port to overflow.

Using bidirectional flow control, the DTE asserts RTS when it is ready to receive data (reversing its role from the unidirectional case), and drops RTS when its input buffer becomes too full. As for the unidirectional case, the DCE asserts CTS when it is ready to receive data, and drops CTS when its input buffer is too full. In each case, the sending equipment stops transmitting whenever it sees the incoming control line drop.


CRTSFL
Change the meaning of RTS (with RTSFLOW and CTSFLOW not set) to allow bidirectional flow control. CRTSFL is included for backward compatibility; ORTSFL should be used in preference.

ORTSFL
Old RTSFLOW; depending on the settings of RTSFLOW and CTSFLOW, ORTSFL determines the type of flow control.

The hardware flow control modes which may be obtained by combining the flags ORTSFL, RTSFLOW, and CTSFLOW are shown in the following table:

Flag combination Flow control mode
ORTSFL | RTSFLOW | CTSFLOW Enable unidirectional flow control
(ORTSFL | RTSFLOW) & ~CTSFLOW Assert RTS when ready to send
(ORTSFL | CTSFLOW) & ~RTSFLOW No effect
ORTSFL & ~(RTSFLOW | CTSFLOW) Enable bidirectional flow control
(RTSFLOW | CTSFLOW) & ~ORTSFL Enable bidirectional flow control
RTSFLOW & ~(CTSFLOW | ORTSFL) No effect
CTSFLOW & ~(RTSFLOW | ORTSFL) Stop transmission when CTS drops
~(ORTSFL | RTSFLOW | CTSFLOW) Disable hardware flow control

 +------------------------------+------------------------------------+
 |Flag combination              | Flow control mode                  |
 +------------------------------+------------------------------------+
 |ORTSFL | RTSFLOW | CTSFLOW    | Enable unidirectional flow control |
 +------------------------------+------------------------------------+
 |(ORTSFL | RTSFLOW) & ~CTSFLOW | Assert RTS when ready to send      |
 +------------------------------+------------------------------------+
 |(ORTSFL | CTSFLOW) & ~RTSFLOW | No effect                          |
 +------------------------------+------------------------------------+
 |ORTSFL & ~(RTSFLOW | CTSFLOW) | Enable bidirectional flow control  |
 +------------------------------+------------------------------------+
 |(RTSFLOW | CTSFLOW) & ~ORTSFL | Enable bidirectional flow control  |
 +------------------------------+------------------------------------+
 |RTSFLOW & ~(CTSFLOW | ORTSFL) | No effect                          |
 +------------------------------+------------------------------------+
 |CTSFLOW & ~(RTSFLOW | ORTSFL) | Stop transmission when CTS drops   |
 +------------------------------+------------------------------------+
 |~(ORTSFL | RTSFLOW | CTSFLOW) | Disable hardware flow control      |
 +------------------------------+------------------------------------+
Older serial devices requiring unidirectional flow control should use the stty settings ortsfl rtsflow ctsflow.

Bidirectional flow control is achieved using the stty settings: ortsfl -rtsflow -ctsflow, or -ortsfl rtsflow ctsflow. These settings are the ones most likely to work with high-speed modems and other modern serial devices. (The settings supersede the older stty settings crtsfl -rtsflow -ctsflow.)

In both the unidirectional and bidirectional cases, you should also specify -clocal -ixon -ixoff to stty. These settings specify that the line has modem control, and that software flow control is disabled.

Software flow control (IXON and IXOFF) should be disabled when using hardware flow control (ORTSFL, RTSFLOW and CTSFLOW). The reverse also applies; disable hardware flow control when using software flow control.

Set all flags explicitly on or off when selecting the flow control mode using stty. For example, to set bidirectional flow control, you would enter: stty ortsfl -ctsflow -rtsflow -ixon -ixoff.

The use of the settings CTSFLOW, RTFLOW, CRTSFL, or ORTSFL is strictly hardware dependent, and should only be used between devices capable of supporting RTS/CTS signaling.

The RS-232 line must also be wired correctly for RTS/CTS handshaking. See the serial(HW) manual page for details of the pin connections for linking DTE to DCE, and DTE to DTE.

Line discipline modes

The line discipline used by the serial driver is chosen by the setting of the c_line field. The basic line discipline used by standard terminal drivers is line discipline 0 (zero).

The c_lflag field of the argument structure is used by the line discipline to control terminal functions. The initial value of this field is 0 (all bits clear).

Line discipline 0 provides the following flags:


ISIG
If set, check each input character against the special control characters INTR, SWTCH and QUIT. If the character matches one of these, perform the function associated with that character (generate the signal associated with that character).

If not set, perform no checking.

Special input functions are only available if ISIG is set. These functions may be disabled individually by changing the value of the control character to an unlikely or impossible value (for example, ``0377'').


ICANON
If set, select canonical processing. This enables the erase and kill edit functions, and the assembly of input characters into lines delimited by NL, EOF and EOL.

If not set, satisfy read requests directly from the input queue. A read will not be satisfied until at least VMIN characters have been received or the timeout value VTIME has expired and at least one character has been input. This allows fast bursts of input to be read efficiently while still allowing single character input. (See the discussion in ``VMIN and VTIME settings''.)


XCASE
If set with ICANON, accept an uppercase letter on input by preceding it with a ``\'' character, and is output preceded by a ``\'' character. In this mode, the following escape sequences are generated on output and accepted on input:

For: Use:
" \"
| \!
~ \^
{ \(
} \)
\ \\

For example, A is input as \a, \n as \\n, and \N as \\\n.


ECHO
Echo characters when they are received.

With ICANON set, the echo modes ECHOE, ECHOK, and ECHONL are possible:


ECHOE
If ECHO is also set, echo the erase character as the ASCII sequence BS SP BS. This clears the previous character on a CRT screen.

If set and ECHO is not set, echo the erase character as the ASCII sequence SP BS.


ECHOK
Echo the NL character after the kill character to emphasize that the line will be deleted. Note that an escape character preceding the erase or kill character removes any special function.

ECHONL
Echo the NL character even if ECHO is not set. This is useful for terminals set to local echo (so-called half duplex).

Unless escaped, the EOF character is not echoed. Because EOT is the default EOF character, this prevents terminals that respond to EOT from hanging up.


NOFLSH
Disable the normal flush of the input and output queues associated with the quit and interrupt characters.

TOSTOP
If set, send the signal SIGTTOU to the process group of a process that tries to write to its controlling terminal if it is not the foreground process group. By default, this signal stops the members of the process group. If TOSTOP is not set, the output generated by the process is output to the current output stream. The TOSTOP flag is only effective if the SVID3 line discipline or the termios structure is used (see termios(M)).

ECHOCTL
If set, echo control characters (except ASCII DC1, DC3, CR, BS, NL, and TAB) as ^C where C is the character obtained by adding 100 octal to the ASCII code for the character. ASCII DEL is echoed as ^?. (SVID3 line discipline only.)

ECHOPRT
If set together with ECHO, echo the first ERASE and WERASE characters in a sequence as backslash (\) followed by the characters being erased. Subsequent ERASE and WERASE characters echo the erased characters in reverse order. The next character that is not ERASE or WERASE outputs a slash (/) before it itself is echoed. (SVID3 line discipline only.)

ECHOKE
If set, echo the ERASE character as BS SP BS. On many terminals, this will erase the ERASE character. Column position is not tracked so the output may be confusing when used on TAB, BACKSPACE, and escaped characters. (SVID3 line discipline only.)

FLUSHO
If set by the FLUSH character being typed, discard data written to the terminal. The program must unset FLUSHO to cancel the effect. (SVID3 line discipline only.)

PENDIN
If set, reprint any input that has not yet been read when the next input character arrives. (SVID3 line discipline only.)

IEXTEN
Enable extended functions. If IEXTEN is set (as it is by default), additional non-POSIX functions are recognized. If IEXTEN is not set, the control characters DISCARD, LNEXT, REPRINT, and WERASE, are not processed, and the settings of ECHOCTL, ECHOKE, ECHOPRT, FLUSHO, PENDIN, and TOSTOP are ignored. The IEXTEN flag is only effective if the SVID3 line discipline or the termios structure is used (see termios(M)).

XCLUDE
Cause any subsequent attempt to open the tty device using open(S) to fail for all users except root. The call returns EBUSY in errno if it fails.

XCLUDE is useful for programs which must have exclusive use of a communications line. It is not intended for the line to the program's controlling terminal.

Clear XCLUDE before the setting program terminates, otherwise subsequent attempts to open the device will fail.

XCLUDE is provided for XENIX backward compatibility.


CIBAUD
The CIBAUD value determines the bit mask for the input baud rate bits. If these are non-zero, they may differ from those defined in CBAUD. Otherwise, the input baud rate is the same as the output baud rate. If the input baud rate is non-zero, to get the input baud rate shift the bits down by IBSHIFT and use the B0 though B38400 defines the determine the bit rate as follow:
   struct termios {
   	t; speed_t output_rate, input_rate;
   

output_rate = (t.c_cflag & CBAUD); if ((input_rate = (t.c_cflag & CIBAUD)) == 0) input_rate = output_rate; else input_rate >>= IBSHIFT};

(SVID3 line discipline only.)

PAREXT
If set, use extended parity for mark and space parity. (SVID3 line discipline only.)

L_SETERASE
Specify that the tty will automatically use <Del> and <Ctrl>H as the ERASE character for a tty rather than using the character set as the ERASE character. This is supported only for SCO OpenServer Release 5.0.6 and later releases.

VMIN and VTIME settings

VMIN and VTIME set the timing characteristics for reading characters when ICANON is not set.

VMIN
The minimum number of characters that should be received when the read is satisfied (that is, the characters are returned to the user).

VTIME
A timer of 0.10 second granularity used to time-out ``bursty'' and short-term data transmissions. The value of VTIME is measured in tenths of seconds.

The four possible values for VMIN and VTIME and their interactions are:


VMIN > 0, VTIME > 0
In this case, VTIME serves as an inter-character timer activated after the first character is received, and reset upon receipt of each character. VMIN and VTIME interact as follows:

As soon as one character is received the inter-character timer is started.

If VMIN characters are received before the inter-character timer expires the read is satisfied.

If the timer expires before VMIN characters are received the characters received to that point are returned to the user.

A read(S) operation will sleep until the VMIN and VTIME mechanisms are activated by the receipt of the first character; thus, at least one character must be returned.


VMIN > 0, VTIME = 0
In this case, because VTIME = 0, the timer plays no role and only VMIN is significant. A read operation is not satisfied until VMIN characters are received.

VMIN = 0, VTIME > 0
In this case, because VMIN = 0, VTIME no longer serves as an inter-character timer, but now serves as a read timer that is activated as soon as the read operation is processed. A read operation is satisfied as soon as a single character is received or the timer expires, in which case, the read operation will not return any characters.

VMIN = 0, VTIME = 0
In this case, return is immediate. If characters are present, they will be returned to the user.

The VMIN and VTIME values are stored in the position for the EOF and EOL characters respectively. VMIN and VTIME are interpreted as EOF and EOL if ICANON is set. Default VMIN and VTIME values are stored in the /usr/include/sys/termio.h file. To change these values, unset ICANON and use stty to change the VMIN and VTIME values as represented by EOF and EOL.

Window size structure

The window size structure winsize is defined in <sys/winsize.h> (included by <sys/termio.h>):
   struct winsize {
           unsigned short ws_row;       /* rows, in characters*/
           unsigned short ws_col;       /* columns, in character */
           unsigned short ws_xpixel;    /* horizontal size, pixels */
           unsigned short ws_ypixel;    /* vertical size, pixels */
   };
This structure is used with the following ioctl commands:

TIOCGWINSZ
The argument arg points to a struct winsize. This contains the terminal size assumed by the terminal driver on exit.

TIOCSWINSZ
On entry, the argument arg points to a struct winsize with new values to be used by the terminal driver. If the new values differ from the old values, the driver signals the process group of the terminal with SIGWINCH.

Limitations

Some flags are only understood if the SVID3 line discipline (svid) is being used and the device driver for this line discipline (ttsv) has been linked into the kernel. See stty(C) for more information.

Future directions

The following lflags are defined in the SCO OpenServer Release 5.0.6 termio.h header file and for the stty(C) command but the kernel capability is not included so they are not functional.

L_EMACS
Specify that tty use a subset of the emacs command line key bindings for inline editing in canonical mode.

L_HISTORY
Specify that the tty supports a history stack of previously entered lines in canonical mode. L_EMACS or L_VI must also be set.

L_VI
Specify that tty use a subset of the vi command line key bindings for inline editing in canonical mode.

When L_EMACS is set, <Ctrl>P or <UpArrow> indicates the previous line; <Ctrl>N or DownArrow indicates the next history line.

When L_VI is set, <Ctrl>K indicates the previous line; <Ctrl>J indicates the next history line.

Files


/usr/include/sys/winsize.h
definition of struct winsize

/usr/include/sys/termio.h
definitions for struct termio, struct termios, and ioctl commands

See also

fork(S), getty(M), ioctl(S), mapchan(F), mapchan(M), read(S), setpgrp(S), shl(C), signal(S), stty(C), termios(M), tty(M)

Standards conformance

termio is conformant with:

ISO/IEC 9945-1:1990, Information technology - Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language] (IEEE Std 1003.1-1990);
AT&T SVID Issue 2;
X/Open CAE Specification, System Interfaces and Headers, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003