Main index | Section 4 | 日本語 | Deutsch | Options |
#include <sys/ioctl.h>
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.
and would be called on the terminal associated with file descriptor zero by the following code fragment:
int pgrp;pgrp = getpgrp(); ioctl(0, TIOCSPGRP, &pgrp);
TIOCSETDint, *ldisc | |
This call is obsolete but left for compatibility. Before FreeBSD 8.0, it would change to the new line discipline pointed to by ldisc. | |
TIOCGETDint, *ldisc | |
Return the current line discipline in the integer pointed to by ldisc. | |
TIOCSBRKvoid | |
Set the terminal hardware into BREAK condition. | |
TIOCCBRKvoid | |
Clear the terminal hardware BREAK condition. | |
TIOCSDTRvoid | |
Assert data terminal ready (DTR). | |
TIOCCDTRvoid | |
Clear data terminal ready (DTR). | |
TIOCGPGRPint, *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. | |
TIOCSPGRPint, *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. | |
TIOCGETAstruct, termios, *term | |
Place the current value of the termios state associated with the device in the termios structure pointed to by term. This is the underlying call that implements the termios(4) tcgetattr() call. | |
TIOCSETAstruct, 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. | |
TIOCSETAWstruct, 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. | |
TIOCSETAFstruct, termios, *term | |
First wait for any output to complete, clear any pending input, then set the termios state associated with the device. This is the underlying call that implements the termios(4) tcsetattr() call with the TCSAFLUSH option. | |
TIOCOUTQint, *num | |
Place the current number of characters in the output queue in the integer pointed to by num. | |
TIOCSTIchar, *cp | |
Simulate typed input. Pretend as if the terminal received the character pointed to by cp. | |
TIOCNOTTYvoid | |
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
provides 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 TIOCSCTTY 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. However, environmental restrictions may prohibit the process from being able to fork() and call the setsid() system call to disassociate it from the controlling terminal. In this case, it must use TIOCNOTTY. | |
TIOCSTOPvoid | |
Stop output on the terminal (like typing ^S at the keyboard). | |
TIOCSTARTvoid | |
Start output on the terminal (like typing ^Q at the keyboard). | |
TIOCSCTTYvoid | |
Make the terminal the controlling terminal for the process (the process must not currently have a controlling terminal). | |
TIOCDRAINvoid | |
Wait until all output is drained, or until the drain wait timeout expires. | |
TIOCGDRAINWAITint, *timeout | |
Return the current drain wait timeout in seconds. | |
TIOCSDRAINWAITint, *timeout | |
Set the drain wait timeout in seconds. A value of zero disables timeouts. The default drain wait timeout is controlled by the tunable sysctl(8) OID kern.tty_drainwait. | |
TIOCEXCLvoid | |
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. | |
TIOCNXCLvoid | |
Clear exclusive use of the terminal. Further opens are permitted. | |
TIOCFLUSHint, *what | |
If the value of the int pointed to by what contains the FREAD bit as defined in <sys/file.h>, 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 (i.e., clears both queues). | |
TIOCGWINSZstruct, 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 fullamp;-screen oriented programs determine the screen size. The winsize structure is defined in <sys/ioctl.h>. | |
TIOCSWINSZstruct, winsize, *ws | |
Set the window size associated with the terminal to be the value in the winsize structure pointed to by ws (see above). | |
TIOCCONSint, *on | |
If on points to a non-zero integer, redirect kernel console output (kernel printf's) to this terminal. If on points to a zero integer, redirect kernel console output back to the normal console. This is usually used on workstations to redirect kernel messages to a particular window. | |
TIOCMSETint, *state | |
The integer pointed to by
state
contains bits that correspond to modem state.
Following is a list of defined variables and the modem state they represent:
| |
TIOCM_LE | Line Enable. |
TIOCM_DTR | |
Data Terminal Ready. | |
TIOCM_RTS | |
Request To Send. | |
TIOCM_ST | Secondary Transmit. |
TIOCM_SR | Secondary Receive. |
TIOCM_CTS | |
Clear To Send. | |
TIOCM_CAR | |
Carrier Detect. | |
TIOCM_CD | Carrier Detect (synonym). |
TIOCM_RNG | |
Ring Indication. | |
TIOCM_RI | Ring Indication (synonym). |
TIOCM_DSR | |
Data Set Ready. | |
This call sets the terminal modem state to that represented by state. Not all terminals may support this.
TIOCMGETint, *state | |
Return the current state of the terminal modem lines as represented above in the integer pointed to by state. | |
TIOCMBISint, *state | |
The bits in the integer pointed to by state represent modem state as described above, however the state is OR-ed in with the current state. | |
TIOCMBICint, *state | |
The bits in the integer pointed to by state represent modem state as described above, however each bit which is on in state is cleared in the terminal. | |
TTY (4) | April 3, 2022 |
Main index | Section 4 | 日本語 | Deutsch | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | Some people open all the windows; wise wives welcome spring by moving the UNIX. | ” |