United States-English |
|
|
HP-UX Reference > Ttermio(7)HP-UX 11i Version 3: February 2007 |
|
NAMEtermio, termios — general terminal interface DESCRIPTIONAll HP-UX asynchronous communications ports use the same general interface, regardless of what hardware is involved. Network connections such as rlogin (see rlogin(1) use the pseudo-terminal interface (see pty(7). This discussion centers around the common features of this interface. Opening a Terminal FileWhen 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 special programs such as getty (see getty(1M)) and become a user's standard input, standard output, and standard error files. If both the O_NDELAY and O_NONBLOCK flags (see open(2)) are clear, an open blocks until the type of modem connection requested (see modem(7)) is completed. If either the O_NDELAY or O_NONBLOCK flag is set, an open succeeds and return immediately without waiting for the requested modem connection to complete. The CLOCAL flag (see Control Modes) can also affect open(2). Process GroupsA terminal can have a foreground process group associated with it. This foreground process group plays a special role in handling signal-generating input characters. Command interpreter processes can allocate the terminal to different jobs (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 can be set or examined by a process, assuming that the permission requirements are met (see tcsetpgrp(3C) or tcgetpgrp(3C)). The terminal interface aids in this allocation by restricting access to the terminal by processes that are not in the foreground process group. A process group is considered orphaned when the parent of every member of the process group is either itself a member of the process group or is not a member of the group's session (see Sessions). SessionsA process that creates a session (see setsid(2) or setpgrp(2)) becomes a session leader. Every process group belongs to exactly one session. A process is considered to be a member of the session of which its process group is a member. A newly created process joins the session of its parent. A process can change its session membership (see setpgid(2) or setpgrp(2)). Usually a session comprises all the processes (including children) created as a result of a single login. The Controlling TerminalA terminal can 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 can be the controlling terminal for at most one session. The controlling terminal for a session is allocated by the session leader. 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(2), the terminal becomes the controlling terminal of the session and the controlling terminal's foreground process group is set to the process group of the session leader. While a controlling terminal is associated with a session, the session leader is said to be the controlling process of the controlling terminal. The controlling terminal is inherited by a child process during a fork() (see fork(2)). A process relinquishes its controlling terminal if it creates a new session with setsid() or setpgrp() (see setsid(2) and setpgrp(2)), or when all file descriptors associated with the controlling terminal have been closed. When the controlling process terminates, the controlling terminal is disassociated from the current session, allowing it to be acquired by a new session leader. A SIGHUP signal is sent to all processes in the foreground process group of the controlling terminal. Subsequent access to the terminal by other processes in the earlier session can be denied (see Terminal Access Control) with attempts to access the terminal treated as if a modem disconnect had been sensed. Terminal Access ControlRead operations are allowed (see Input Processing and Reading Data) from processes in the foreground process group of their controlling terminal. If a process is not in the foreground process group of its controlling terminal, the process and all member's of its process group are considered to be in a background process group of this controlling terminal. All attempts by a process in a background process group to read from its controlling terminal will be denied. If denied and the reading process is ignoring or blocking the SIGTTIN signal, or the process (on systems that implement vfork separately from fork) has made a call to vfork(2) but has not yet made a call to exec(2), or the process group of the reading process is orphaned, read() returns -1 with errno set to EIO and no signal is sent. In all other cases where the read is denied, the process group of the reading process will be sent a SIGTTIN signal. The default action of the SIGTTIN signal is to stop the process to which it is sent. If the process is in the foreground process group of its controlling terminal, write operations are allowed (see Writing Data and Output Processing). Attempts by a process in a background process group to write to its controlling terminal are denied if TOSTOP (see Local Modes) is set, the process is not ignoring and not blocking the SIGTTOU signal, and the process (on systems that implement vfork separately from fork) has not made a call to vfork(2) without making a subsequent call to exec(2). If the write is denied and the background process group is orphaned, the write() returns -1 with errno set to EIO. If the write is denied and the background process group is not orphaned, the SIGTTOU signal is sent to the process group of the writing process. The default action of the SIGTTOU signal is to stop the process to which it 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. Input Processing and Reading DataA terminal device associated with a terminal device file can operate in full-duplex mode, so that data can arrive, even while data output is occurring. Each terminal device file has an input queue associated with it into which incoming data is stored by the system before being read by a process. The system imposes a limit, MAX_INPUT, on the number of characters that can be stored in the input queue. This limit is dependent on the particular implementation, but is at least 256. When the input limit is reached, all saved characters are discarded without notice. All input is processed either in canonical mode or non-canonical mode (see 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. For example, such processing can include echoing, 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 operate in full-duplex mode. The manner in which data is provided to a process reading from a terminal device file depends on whether the terminal device file is in canonical or non-canonical mode. Another dependency is whether the O_NONBLOCK or O_NDELAY flag is set by either open(2) or fcntl(2). If the O_NONBLOCK and O_NDELAY flags are both clear, the read request is blocked until data is available or a signal is received. If either the O_NONBLOCK or O_NDELAY flag is set, the read request completes without blocking in one of three ways:
The availability of data depends upon 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 (Erase and Kill Processing)In canonical mode input processing, terminal input is processed in units of lines, where a line is delimited by a new-line (NL) character, an end-of-file (EOF) character, or an end-of-line character (EOL) or (EOL2). See Special Characters for more information on NL, EOF, EOL, and EOL2. This means that a read request does not return until an entire line has been typed or a signal has been received. Also, no matter how many characters 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 characters can be requested in a read, even one, without losing information. MAX_CANON is the limit on the number of characters in a line. This limit varies with each particular implementation, but is at least 256. When the MAX_CANON limit is reached, all characters in the current undelimited line are discarded without notice. Erase and kill processing occur when any of three special characters, the ERASE, WERASE, or KILL characters (see Special Characters), is received. This processing affects data in the input queue that has not yet been delimited by a NL, EOF, EOL, or EOL2 character. This undelimited data makes up the current line. The ERASE character deletes the last character in the current line, if one exists. The WERASE character deletes the last word in the current line, if one exists. A word is defined as a series of non-blank characters (tabs are equivalent to blanks). The KILL character deletes all data in the current line, if any, and optionally outputs a new-line (NL) character. These characters operate on a key-stroke basis, independent of any backspacing or tabbing that may have preceded them. ERASE, WERASE, and KILL characters have no effect if the current line is empty. ERASE, WERASE, and KILL characters are not placed in the input queue. Non-Canonical Mode Input Processing (MIN/TIME Interaction)In non-canonical mode input processing, input characters 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 (see termios Structure) are used to determine how to process the characters received. MIN represents the minimum number of characters that should be received before read() successfully returns. TIME is a timer of 0.10 second granularity that is used to timeout bursty and short term data transmissions. The four possible cases for MIN and TIME and their interactions are described below. Case A: MIN > 0, TIME > 0 In this case, TIME serves as an inter-character timer and is activated after the first character is received. Since it is an inter-character timer, it is reset after each character is received. The interaction between MIN and TIME is as follows:
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 characters are received after any previous read completes (that is, the pending read blocks until MIN characters are received), or a signal is received. A program that uses this case to handle record-based terminal I/O can block indefinitely in the read operation. Case C: MIN = 0, TIME > 0 In this case, since the value of MIN is zero, TIME no longer represents an inter-character 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 character is received or the read timer expires. If the timer expires, no character is returned. If the timer does not expire, the only way the read can be satisfied is by a character being received. A read cannot block indefinitely waiting for a character because if no character is received within TIME Ч 0.10 seconds after the read is initiated, read() returns a value of zero, having read no data. Case D: MIN = 0, TIME = 0 The number of characters requested or the number of characters currently available, whichever is less, is returned without waiting for more characters to be input. If no characters are available, read() returns a value of zero, having read no data. Some points to note about MIN and TIME:
These two points highlight the dual purpose of the MIN/TIME feature. Cases A and B (where MIN > 0 ) exist to handle burst mode activity (such as file transfer programs) where a program would like to process at least MIN characters at a time. In case A, the inter-character timer is activated by a user as a safety measure while in case B it is turned off. Cases C and D exist to handle single character timed transfers. These cases are readily adaptable to screen-based applications that need to know if a character is present in the input queue before refreshing the screen. In case C the read is timed, while in case D it is not. Another important note is that MIN is always just a minimum. It does not denote a record length. For example, if a program initiates a read of 20 characters when MIN is 10 and 25 characters are present, 20 characters will be returned to the user. Had the program requested all characters, all 25 characters would be returned to the user. Furthermore, if TIME is greater than zero and MIN is greater than MAX_INPUT, the read will never terminate as a result of MIN characters being received because all the saved characters are discarded without notice when MAX_INPUT is exceeded. If TIME is zero and MIN is greater than MAX_INPUT, the read will never terminate unless a signal is received. Special CharactersCertain characters have special functions on input, output, or both. Unless specifically denied, each special character can be changed or disabled. To disable a character, set its value to _POSIX_VDISABLE (see unistd(5)). These special functions and their default character values are:
The special characters are assigned their default character values when the terminal port is opened. The default values used are those specified by the System V Interface Definition, Third Edition (SVID3), except for the WERASE (Control-W) and LNEXT (Control-V) characters which are set to _POSIX_VDISABLE to maintain binary compatibility with previous releases of HP-UX. The default character values assigned when the port is opened can be changed for all ports on a system wide basis through the use of the stty command (see stty(1)). The character values may also be changed for a specific port after it is opened using the stty command. The NL and CR characters cannot be changed or disabled. The character values for the remaining special characters can be changed or disabled to suit individual tastes. If ICANON is set (see Local Modes), the ERASE, KILL, and EOF characters can be escaped by a preceding \ character, in which case no special function is performed. These characters, and the remaining special characters, may also be escaped by preceding them with the LNEXT character (see LNEXT above). If two or more special characters have the same value, the function performed when the character is processed is undefined. Modem DisconnectIf a modem disconnect is detected by the terminal interface for a controlling terminal, and if CLOCAL is clear in the c_cflag field for the terminal (see Control Modes), the SIGHUP signal is sent to the controlling process of the controlling terminal. Unless other arrangements have been made, this causes the controlling process to terminate. Any subsequent read from the terminal device returns with an end-of-file indication until the device is closed. 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. Closing a Terminal Device FileThe last process to close a terminal device file causes any output not already sent to the device to be sent to the device even if output was suspended. This last close always blocks (even if non-blocking I/O has been specified) until all output has been sent to the terminal device. Any input that has been received but not read is discarded. Writing Data and Output ProcessingWhen characters are written, they are placed on the output queue. Characters on the output queue are transmitted to the terminal as soon as previously-written characters are sent. These characters are processed according to the c_oflag field (see Output Modes). Input characters are echoed by putting them in the output queue as they arrive. If a process produces characters for output more rapidly than they can be sent, the process is suspended when its output queue exceeds some limit. When the queue has drained down to some threshold, the process is resumed. termios StructureRoutines that need to control certain terminal I/O characteristics can do so by using the termios structure as defined in the header file <termios.h>. The structure is defined as follows: #define NCCS 16 struct termios { tcflag_t c_iflag; /* input modes */ tcflag_t c_oflag; /* output modes */ tcflag_t c_cflag; /* control modes */ tcflag_t c_lflag; /* local modes */ tcflag_t c_reserved; /* reserved for future use */ cc_t c_cc[NCCS]; /* control chars */ }; The special characters are defined by the array c_cc. The relative positions and default values for each special character function are as follows:
termio StructureThe termio structure has been superseded by the termios structure and is provided for backward compatibility with prior applications (see termio Caveats). The structure is defined in the header file <termio.h> and is defined as follows: #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; /* local modes */ char c_line; /* line discipline */ unsigned char c_cc[NCC]; /* control chars */ }; ModesThe next four sections describe the specific terminal characteristics that can be set using the termios and termio structures (see termio Caveats). Any bits in the modes fields that are not explicitly defined below are ignored. However, they should always be clear to prevent future compatibility problems. Input ModesThe c_iflag field describes the basic terminal input control:
A break condition is defined as a sequence of zero-value bits that continues for more than the time to send one character. For example, a character framing or parity error with data all zeros is interpreted as a single break condition. If IGNBRK is set, the break condition is ignored. Therefore the break condition cannot be read by any process. If IGNBRK is clear and BRKINT is set, the break condition flushes both 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 character, or if PARMRK is set, as the three-character sequence \377, \0, \0. If IGNPAR is set, characters with other framing and parity errors (other than break) are ignored. If PARMRK is set, and IGNPAR is clear, a character with a framing or parity error (other than break) is read as the three-character sequence: \377, \0, X, where X is the data of the character received in error. To avoid ambiguity in this case, if ISTRIP is clear, a valid character of \377 is read as \377, \377. If both PARMRK and IGNPAR are clear, a framing or parity error (other than break) is read as the character \0. If INPCK is set, input parity checking is enabled. If INPCK is clear, input parity checking is disabled. Whether input parity checking is enabled or disabled is independent of whether parity detection is enabled or disabled (see Control Modes). If PARENB is set (see Control Modes) and INPCK is clear, parity generation is enabled but input parity checking is disabled; the hardware to which the terminal is connected will recognize the parity bit, but the terminal special file will not check whether this bit is set correctly or not. The following table shows the interrelationship between the flags IGNBRK, BRKINT, IGNPAR, and PARMRK. The column marked Input gives various types of input characters received, indicated as follows:
Items enclosed in brackets indicate one or more of the conditions are true. If the INPCK flag is clear, characters received with parity errors are not processed according to this table, but instead, as if no parity error had occurred. Under the flag columns, Set indicates the flag is set, Clear indicates the flag is not set, and X indicates the flag may be set or clear. The column labeled Read shows the results that will be passed to the application code. A — indicates that no character or condition is passed to the application code. The value SIGINT indicates that no character is returned, but that the SIGINT signal is sent to the foreground process group of the controlling terminal.
If ISTRIP is set, valid input characters are first stripped to 7-bits, otherwise all 8-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 clear and ICRNL is set, a received CR character is translated into a NL character. If IUCLC is set, a received uppercase alphabetic character is translated into the corresponding lowercase 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 and IXON are set, any input character without a framing or parity error restarts output that has been suspended. When these three flags are set, output suspended, and an input character received with a framing or parity error, output resumes if processing it results in data being read. When IXON is set, START and STOP characters are not read, but merely perform flow control functions. When IXON is clear, the START and STOP characters are read. If IXOFF is set, start/stop input control is enabled. The system transmits a STOP character when the number of characters in the input queue exceeds a system defined value (high water mark). This is intended to cause the terminal device to stop transmitting data in order to prevent the number of characters in the input queue from exceeding MAX_INPUT. When enough characters have been read from the input queue that the number of characters remaining is less than another system defined value (low water mark), the system transmits a START character which is intended to cause the terminal device to resume transmitting data (without risk of overflowing the input queue). In order to avoid potential deadlock, IXOFF is ignored in canonical mode whenever there is no line delimiter in the input buffer. In this case, the STOP character is not sent at the high water mark, but will be transmitted later if a delimiter is received. If all complete lines are read from the input queue leaving only a partial line with no line delimiter, the START character is sent, even if the number of characters is still greater than the low water mark. When ICANON is set and the input stream contains more characters between line delimiters than the high water mark allows, there is no guarantee that IXOFF can prevent buffer overflow and data loss, because the STOP character may not be sent in time, if at all. If IMAXBEL is set, the ASCII BEL character is echoed if the input queue overflows. Further input is not stored, but any input present in the input queue is not discarded. If IMAXBEL is clear, no ASCII BEL character is echoed, and the input already present in the input queue is discarded when the input queue overflows. The initial input control value is all bits clear. Output ModesThe c_oflag field specifies the system treatment of output:
If OPOST is set, output characters are post-processed as indicated by the remaining flags; otherwise characters are transmitted without change. If OLCUC is set, a lowercase alphabetic character is transmitted as the corresponding uppercase character. This function is often used in conjunction with IUCLC. 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. If ONLRET is clear, the NL character is assumed to perform only the line-feed function; the delays specified for NL are used and the column pointer remains unchanged. For all of these cases, the column pointer is always 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. The values of NL0, CR0, TAB0, BS0, VT0, and FF0 indicate no delay. If OFILL is set, fill characters are transmitted for delay instead of a timed delay. This is useful for high baud rate terminals, that 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, carriage-return delays are used instead of the new-line delays. If OFILL is set, two fill characters are transmitted. Carriage-return delay type 1 depends on the current column position; type 2 is about 0.10 seconds; type 3 about 0.15 seconds. If OFILL is set, delay type 1 transmits two fill characters; type 2, four fill characters. Horizontal-tab delay type 1 is depends 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 are transmitted for any delay. Backspace delay lasts about 0.05 seconds. If OFILL is set, one fill character is transmitted. The actual delays depend on line speed and system load. The initial output control value is all bits clear. Control ModesThe c_cflag field describes the hardware control of the terminal:
The CBAUD bits specify the baud rate. The zero baud rate, B0, is used to hang up the connection. If B0 is specified, the modem control lines (see modem(7)) cease to be asserted. Normally, this disconnects the line. For any particular hardware, impossible speed changes are ignored. CBAUD is provided for use with the termio structure. When the termios structure is used, several routines are available for setting and getting the input and output baud rates (see termios Structure Related Functions). The CSIZE bits specify the character size in bits for both transmission and reception. 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, many devices require two stop bits. If PARENB is set, parity generation is enabled (a parity bit is added to each output character). Furthermore, parity detection is enabled (incoming characters are checked for the correct parity). If PARENB is set, PARODD specifies odd parity if set; otherwise even parity is used. If PARENB is clear, both parity generation and parity checking are disabled. If CREAD is set, the receiver is enabled. Otherwise no characters can be received. The specific effects of the HUPCL and CLOCAL bits depend on the mode and type of the modem control in effect. See modem(7) for the details. If HUPCL is set, the modem control lines for the port are lowered (disconnected) when the last process using the open port closes it or terminates. 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 read() waits for a modem connection to complete. However, if either the O_NDELAY or the O_NONBLOCK flags are set or CLOCAL is set, the open() returns immediately without waiting for the connection. If CLOCAL is set, see Modem Disconnect for the effects of read() and write() for those files for which the connection has not been established or has been lost. LOBLK is used by the shell layers facility (see shl(1)). The shell layers facility is not part of the general terminal interface, and the LOBLK bit is not examined by the general terminal interface. The initial hardware control value after open is B300, CS8, CREAD, and HUPCL. Local ModesThe c_lflag field is used to control terminal functions.
If ISIG is set, each input character is checked against the special control characters INTR, QUIT, SUSP, and DSUSP (see Process Group Control IOCTL Commands). If an input character matches one of these control characters, the function associated with that character is performed and the character is discarded. If ISIG is clear, no checking is done and the character is treated as a normal data character. Thus these special input functions are possible only if ISIG is 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, EOL, or EOL2. If ICANON is clear, read requests are satisfied directly from the input queue. A read blocks until at least MIN characters have been received or the timeout value TIME has expired between characters. (See Non-Canonical Mode Input Processing (MIN/TIME Interaction)). This allows fast bursts of input to be read efficiently while still allowing single-character input. The time value represents tenths of seconds. If XCASE is set, and if ICANON is set, an uppercase letter is accepted 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 example, A is input as \a, \n as \\n, and \N as \\\n. XCASE would normally be used in conjunction with IUCLC and OLCUC for terminals that support only the first-sixty-four-character limited character set. In this case, IUCLC processing is done before XCASE for input, and processing is done after XCASE for output. Therefore typing A causes an a to be read because of IUCLC, and typing \A causes an A to be read since IUCLC produces \a which is turned into A by the XCASE processing. If ECHO is set, characters are echoed back to the terminal when received. If ECHO is clear, characters are not echoed. When 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, EOL and EOL2 as described in Canonical Mode Input Processing. Furthermore, the following echo functions are possible. If ECHO and ECHOE are set, the ERASE and WERASE characters are echoed as the three-character ASCII sequence BS SP BS, which clears the last character or word from the CRT screen. If ECHO and ECHOPRT are set, and ECHOE is clear, the first ERASE and WERASE character in a sequence echoes a backslash (\) followed by the characters being erased. Subsequent ERASE or WERASE characters echo the characters being erased in reverse order. The next non-erase character causes a slash (/) to be typed before it is echoed. If ECHOKE and ECHO are set, the KILL character is echoed by erasing each character on the line from the CRT screen using using the method selected by ECHOE and ECHOPRT. If ECHOCTL and ECHO are set, all control characters (characters with codes between 0 and 37 octal) other than ASCII TAB, ASCII NL, the START and STOP characters, ASCII CR, and ASCII BS are echoed as ^char, where char is the character given by adding 100 octal to the control character's code. If ECHOK is set and ECHOKE is not set, the NL character is echoed after the kill character to emphasize that the line is being deleted. If ECHONL is set, the NL character is echoed even if ECHO is clear. This is useful for terminals set to local echo (that is, half duplex). Unless escaped, the EOF character is not echoed. Because ASCII EOT is the default EOF character, this prevents terminals that respond to EOT from hanging up. If NOFLSH is set, the normal flush of the input and output queues associated with quit, interrupt, and suspend characters is not done. However, NOFLSH does not affect the flushing of data upon receipt of a break when BRKINT is set. If the TOSTOP bit is set, an attempt by a process that is not in the foreground process group to write to its controlling terminal will be denied when the process is not ignoring and not blocking the SIGTTOU signal. If the write is denied and the process is a member of an orphaned process group write() returns -1 and sets errno to EIO and no signal is sent. If the write is denied and the process is a not a member of an orphaned process group, the SIGTTOU signal is sent to that process group. If FLUSHO is set, data written to the terminal device is discarded. This bit is set by a program. A program can cancel the FLUSHO effect by clearing FLUSHO. If PENDIN is set, any input that has not been read is reprocessed and possibly re-echoed when the next character arrives as input. If ICANON is set, the ERASE, KILL, and EOF characters can be escaped by a preceding \ character, in which case no special function is done. IEXTEN must be set before the ECHOCTL, ECHOPRT, ECHOKE, FLUSHO, and PENDIN functions are allowed. In addition, the special characters WERASE and LNEXT are allowed only if IEXTEN is set. IEXTEN does not affect any other functions. The initial local control value is all-bits-clear. Special Control CharactersSpecial control characters are defined in the array c_cc. All of these special characters can be changed. The subscript name and description for each element in both canonical and non-canonical mode are shown in the following table.
termios Structure-Related FunctionsThe following functions are provided when using the termios structure. Note that the effects on the terminal device of the cfsetispeed() and cfsetospeed() functions do not become effective until the tcsetattr() function is successfully called. Refer to the appropriate manual entries for details.
termio Structure-Related OCTL CommandsSeveral ioctl() system calls apply to terminal files that use the termio structure (see termio Structure). If a requested command is not recognized, the request returns -1 with errno set to EINVAL. ioctl() system calls that reference the termio structure have the form: ioctl (fildes, command, arg) struct termio *arg; Commands using this form are:
termio CaveatsOnly the first eight special control characters (see termios Structure) can be set or returned. The values of indices VEOL and VEOF are the same as indices VTIME and VMIN respectively. Hence if ICANON is set, VEOL or VTIME is the additional end-of-line character and VEOF or VMIN is the end-of-file character. If ICANON is clear, VEOL or VTIME is the inter-character-timer value and VEOF or VMIN is the minimum number of characters desired for reads. Structure-Independent FunctionsThe following functions which are independent of both the termio and termios structures are provided for controlling terminals. Refer to the appropriate manual entries for details.
System Asynchronous I/O IOCTL CommandsThe following ioctl() system calls provide for system asynchronous I/O and have the form: ioctl (fildes, command, arg) int *arg; Commands using this form are:
Line Control IOCTL CommandsSeveral ioctl() system calls control input and output. Some of these calls have the form: ioctl (fildes, command, arg) int arg; Commands using this form are:
Other calls have the form: ioctl (fildes, command, arg) int *arg; Commands using this form are:
Non-blocking I/O IOCTL CommandsNon-blocking I/O is easily provided via the O_NONBLOCK and O_NDELAY flags available in both open(2) and fcntl(2). The commands in this section are provided for backward compatibility with previously developed applications. ioctl() system calls that provide a style of non-blocking I/O different from O_NONBLOCK and O_NDELAY have the form: ioctl (fildes, command, arg) int *arg; Commands using this form are:
Process Group Control IOCTL CommandsThe process group control features described here (except for setting and getting the delayed stop process character) are easily implemented using the functions tcgetattr(), tcsetattr(), tcgetpgrp(), tcsetpgrp(), and tcsetsid(), (see tcattribute(3C), tcgetpgrp(3C), tcsetpgrp(3C), and tcgetsid(3C) respectively). The following structure, used with process group control, is defined in <bsdtty.h>: struct ltchars { unsigned char t_suspc; /* stop process character*/ unsigned char t_dsuspc; /* delayed stop process character*/ unsigned char t_rprntc; /* reserved; must be '_POSIX_VDISABLE'*/ unsigned char t_flushc; /* reserved; must be '_POSIX_VDISABLE'*/ unsigned char t_werasc; /* reserved; must be '_POSIX_VDISABLE'*/ unsigned char t_lnextc; /* reserved; must be '_POSIX_VDISABLE'*/ }; The initial value for all these characters is _POSIX_VDISABLE, which causes them to be disabled. The meaning for each character is as follows:
Attempts to set any of the reserved characters to a value other than _POSIX_VDISABLE cause ioctl() to return -1 with errno set to EINVAL with no change in value of the reserved character. ioctl() system calls that use the above structure have the form: ioctl (fildes, command, arg) struct ltchars *arg; Commands using this form are:
Additional process group control ioctl() system calls have the form: ioctl (fildes, command, arg) unsigned int *arg; Commands using this form are:
Setting or clearing LTOSTOP is equivalent to setting or clearing the TOSTOP flag (see Local Modes). If LTOSTOP is set and a process is not in the foreground process group of its controlling terminal, a write by the process to its controlling terminal may be denied (see Terminal Access Control). Terminal Size IOCTL CommandsThe following ioctl() system calls are used to get and set terminal size information for the terminal referenced by fildes. These ioctl() system calls use the winsize structure to get and set the terminal size information. The winsize structure, defined in <termios.h>, has the following members : unsigned short ws_row; /* Rows, in characters */ unsigned short ws_col; /* Columns, in characters */ unsigned short ws_xpixel; /* Horizontal size, in pixels */ unsigned short ws_ypixel; /* Vertical size, in pixels */ The initial values for all elements of terminal size are zero. The values for terminal size are neither set nor used by the general terminal interface, and have no effect on the functionality of the general terminal interface. The values for terminal size are set and used only by applications that access them through the terminal-size ioctl() system calls (see ioctl(2)). ioctl() system calls that use the above structure have the form: ioctl (fildes, command, arg) struct winsize *arg; Commands using this form are:
Console Output Redirection IOCTL CommandOutput which would normally be sent to the system console may be redirected to any other TTY device or pseudo-device in the system. The ioctl() system call used to control console output redirection has the form: ioctl (fildes, command, arg) int arg; The command using this form is:
WARNINGSVarious HP-UX implementations use non-serial interfaces that look like terminals (such as bit-mapped graphics displays) or ``smart cards'' that cannot implement the exact capabilities described above. Therefore, not all systems can exactly meet the standard stated above. Each implementation is required to state any deviations from the standard as part of its system-specific documentation.
The general terminal interface uses a system resource known as a cblock to store data being transmitted or received through a communications port. These cblocks are continuously used and freed for reuse as data pass through the system. If too few cblocks are configured in the system, the cblock pool may be temporarily or permanently exhausted, and data loss, system hangs, or reduced system performance can result. If cblock exhaustion is suspected, you can examine the system message buffer with dmesg (see dmesg(1M)) for messages indicating cblock exhaustion has occurred. Or, you can use adb (see adb(1)) if examining the corefile of a dump. The message format is WARNING: cblock exhaustion occurred n times where n indicates the number of times the operating system has requested a cblock and none could be provided. If this message is observed, the kernel should be reconfigured to generate a larger number of cblocks. A cblock is 32 bytes in length. The default number of cblocks configured in the system is defined to be 8292. This can be overridden by using the optional tunable system parameter nclist to specify the desired number of cblocks to be used in the system. SAM or kctune(1M) may be used to change the nclist value. DEPENDENCIESWorkstationsBuilt-in serial ports on workstation machines support the following additional baud rate settings: 57600, and 115200. An RS-232-to-RS-422 converter may be required to achieve practical cable lengths at these baud rates (because RS-232 only specifies up to 19200 baud). Timed delays are not supported. Built-in serial ports on workstation systems have RTS and CTS flow control capability, configurable receive FIFO trigger levels, and a configurable transmit limit. RTS/CTS hardware handshaking can be enabled through a bit in the device file minor number, through an ioctl() call (see termiox(7)), or through the stty command (see stty(1)). The receive FIFO trigger level is configurable through two bits in the device file minor number. The receive FIFO trigger level is used to set the level at which a receive interrupt is generated to the system. Setting a smaller value for the receive FIFO trigger level enables the system to react more quickly to receipt of characters. However, using a smaller trigger level increases system overhead to process the additional interrupts. A higher receive FIFO trigger level reduces the system interrupt overhead for heavy inbound data traffic at the cost of less time for the system to read data from the hardware before receive FIFOs are overrun. When using RTS flow control, the receive FIFO trigger level also determines the point at which the hardware lowers RTS to protect the receive FIFO. Use of a higher receive FIFO trigger level also reduces XOFF flow control responsiveness because, under light inbound data flow conditions, receipt of the XOFF character by the system is slightly delayed. Choice of the appropriate receive FIFO trigger level should be based upon how the serial port is to be used. For most applications a receive FIFO trigger level of 8 (c3,c2 = 10) is suggested. Two bits in the device file minor number specify the transmit limit, the number of characters which are successively loaded into the transmit FIFO. Setting a smaller transmit limit allows the transmitter to be more responsive to flow control either from receipt of an XOFF character or de-assertion of CTS at the cost of increased system interrupt overhead. Setting a larger transmit limit reduces interrupt overhead but is not as responsive to flow control since the remainder of the transmit FIFO can be transmitted even after the transmitter is flow controlled. When communicating with devices which have little tolerance for data receipt after flow control, one must choose the transmit limit appropriately. Device File Minor NumberWorkstation device file minor numbers take the form: 0xIIC0HM where:
ServersTimed output delays are not directly supported. If used, an appropriate number of fill characters (based on the current baud rate) is output. The total time to output the fill characters is at least as long as the time requested. The system specified input flow control values are as follows: low water mark is 60, high water mark is 180, and maximum allowed input is 512. The HP 98196A (formerly 27140A option 800) interface does not support the following hardware settings:
The HP A1703-60003 and the HP 28639-60001 interfaces do not support baud rates above 9600. Furthermore, changing the following hardware settings on port 0 from the default (9600 baud, 8 bit characters, 1 stop bit, no parity) is not supported:
The HP J2094A interface does not support baud rates above 19200. The HP J2094A supports RTS and CTS flow control. The RTS/CTS hardware handshaking can be enabled through a bit in the device file minor number, through an ioctl() call (see termiox(7)), or through the stty command (see stty(1)). Device File Minor NumberServer device file minor numbers take the form: 0xIIPPHM where:
AUTHORtermios was developed by HP and the IEEE Computer Society. termio was developed by HP, AT&T, and the University of California, Berkeley. SEE ALSOadb(1), shl(1), stty(1), dmesg(1M), kctune(1M), mknod(1M), fork(2), ioctl(2), setpgid(2), setsid(2), signal(2), stty(2), cfspeed(3C), tcattribute(3C), tccontrol(3C), tcgetpgrp(3C), tcgetsid(3C), tcsetpgrp(3C), privileges(5), signal(5), unistd(5), modem(7), sttyV6(7), termiox(7), tty(7). |
Printable version | ||
|