TTY (4)

xiaoxiao2021-03-06  118

Manual Reference Pages - TTY (4) NAME tty - general terminal interface CONTENTS Synopsis Description Terminal Special Files Line disciplines Terminal File Operations Terminal File Request Descriptions See Also SYNOPSIS .In sys / ioctl.h DESCRIPTION This section describes the interface to the terminal drivers in the system. Terminal Special Files Each hardware terminal port on the system usually has a terminal special device file associated with it in the directory '' / dev / '' (for example, '' / dev / tty03 ''). When a user logs into the system on one of these hardware terminal ports, the system has already opened the associated device and prepared the line for normal interactive use (see getty 8.) There is also a special case of a terminal file that connects not to a hardware terminal port, but to another program on the other side. These special terminal devices are called ptys and provide the mechanism necessary to give users the same interface to the system when logging in over a network (usi ng rlogin (1), or telnet (1) for example). Even in these cases the details of how the terminal file was opened and set up is already handled by special software in the system. Thus, users do not normally need to worry about the details of how these lines are opened or used. Also, these lines are often used for dialing out of a system (through an out-calling modem), but again the system provides programs that hide the details of accessing these terminal special files (see tip (1)). When an interactive user logs in, the system prepares the line to behave in a certain way (called a line discipline), the particular details of which is described in stty (1) at the command level, And in Termios (4) at the programming level.

A user may be concerned with changing settings associated with his particular login terminal and should refer to the preceding man pages for the common cases. The remainder of this man page is concerned with describing details of using and controlling terminal devices at a low level, such as that possibly required by a program wishing to provide features similar to those provided by the system. Line disciplines A terminal file is used like any other file in the system in that it can be opened, read, and written to using standard system calls. For each existing terminal file, there is a software processing module called a line discipline is associated with it. The line discipline essentially glues the low level device driver code with the high level generic interface routines (such as read (2) and write (2 ))), and is responsible for importing the device. When a Terminal File is first Opened by a program, The Default Line Discipline Called The Termios Line D iscipline is associated with the file. This is the primary line discipline that is used in most cases and provides the semantics that users normally associate with a terminal. When the termios line discipline is in effect, the terminal file behaves and is operated according to the Rules Described in Termios (4). Please Refer to That Man Page for a Full Description of The Terminal Semantics.

The operations described here generally represent features common across all line disciplines, however some of these calls may not make sense in conjunction with a line discipline other than termios, and some may not be supported by the underlying hardware (or lack thereof, as in the case of ptys). Terminal File Operations All of the following operations are invoked using the ioctl (2) system call. Refer to that man page for a description of the request and argp parameters. In addition to the ioctl requests defined here, the specific line discipline in effect will define other requests specific to it (actually termios (4) defines them as function calls, not ioctl requests.) The following section lists the available ioctl requests. The name of the request, a description of its purpose, and The Typed Argp Parameter (if any) deflated. for example and wouldle = TTYDISC; ioctl (0, TIOCSETD, & ldisc); Terminal File Request Descriptions TIOCSETD int * ldisc Change to the new line discipline pointed to by ldisc The available line disciplines are listed inand currently are.:

TTYDISC Termios interactive line discipline. TABLDISC Tablet line discipline. SLIPDISC Serial IP line discipline. PPPDISC PPP line discipline. NETGRAPHDISC Netgraph ng_tty (4) line discipline. TIOCGETD int * ldisc Return the current line discipline in the integer pointed to by ldisc. TIOCSBRK void Set the terminal hardware into BREAK condition. TIOCCBRK void Clear the terminal hardware BREAK condition. TIOCSDTR void Assert data terminal ready (DTR). TIOCCDTR void Clear data terminal ready (DTR). TIOCGPGRP int * tpgrp Return the current process group with which the terminal is associated in the integer pointed to by tpgrp. This is the underlying call that implements the termios (4) tcgetattr call. TIOCSPGRP int * tpgrp Associate the terminal with the process group (as an integer) pointed to by tpgrp. This is the underlying Call That Implements The Termios (4) TcSetattr Call. Tiocgeta Struct Termios * Term Place The Current Value of The Termios State Associated with The Device in The Termios ST ructure pointed to by term. This is the underlying call that implements the termios (4) tcgetattr call. TIOCSETA struct termios * term Set the termios state associated with the device immediately. This is the underlying call that implements the termios (4) tcsetattr call with the TCSANOW option. TIOCSETAW struct termios * term First wait for any output to complete, then set the termios state associated with the device. This is the underlying call that implements the termios (4) tcsetattr call with the TCSADRAIN option. TIOCSETAF struct termios * Term First Wait for any Output to Complete, Clear Any Pending Input, The Set The Termios State Associated with the device.

This is the underlying call that implements the termios (4) tcsetattr call with the TCSAFLUSH option. TIOCOUTQ int * num Place the current number of characters in the output queue in the integer pointed to by num. TIOCSTI char * cp Simulate typed input. Pretend as if the terminal received the character pointed to by cp. TIOCNOTTY void This call is obsolete but left for compatibility. in the past, when a process that did not have a controlling terminal (see The Controlling Terminal in termios (4)) first opened a terminal device, it acquired that terminal as its controlling terminal. For some programs this was a hazard as they did not want a controlling terminal in the first place, and this provided a mechanism to disassociate the controlling terminal from the calling process. It must be called by opening the file / dev / tty and calling TIOCNOTTY on that file descriptor The current system does not allocate a controlling terminal to a process on an open call:. there is a specific ioctl called TIO . SCTTY to make a terminal the controlling terminal In addition, a program can fork and call the setsid system call which will place the process into its own session - which has the effect of disassociating it from the controlling terminal This is the new and preferred. method for programs to lose their controlling terminal. TIOCSTOP void Stop output on the terminal (like typing ^ S at the keyboard). TIOCSTART void Start output on the terminal (like typing ^ Q at the keyboard). TIOCSCTTY void Make the terminal the controlling TiOCDRAIN VOID WAITLUSICEXCL VOID SET EXCLUSIVE OUCEXCL VOID TIOCDRAIN VOID. TIOCDRAIN VOID. TIOCEXCL VOID SET Exclusive Use on The Terminal.

No further opens are permitted except by root Of course, this means that programs that are run by root (or setuid) will not obey the exclusive setting -. Which limits the usefulness of this feature TIOCNXCL void Clear exclusive use of the terminal Further.. opens are permitted. TIOCFLUSH int * what If the value of the int pointed to by what contains the FREAD bit as defined in, then all characters in the input queue are cleared. If it contains the FWRITE bit, then all characters in the output queue are cleared. If the value of the integer is zero, then it behaves as if both the FREAD and FWRITE bits were set (ie clears both queues). TIOCGWINSZ struct winsize * ws Put the window size information associated with the terminal in the winsize structure pointed to by ws. The window size structure contains the number of rows and columns (and pixels if appropriate) of the devices attached to the terminal. It is set by user software and is the means by which most full-screen oriented programs d Etermine the screen size. The Winsize Structure is defined in

转载请注明原文地址:https://www.9cbs.com/read-103292.html

New Post(0)