vc-reset-tty
1
user commands
nosh
vc-reset-tty
chain-load utility for resetting virtual console terminals
vc-reset-tty
--hard-reset
--no-utf8
--no-tostop
--text-mode
next-prog
Description
vc-reset-tty is a chain-loading utility that attempts to initialize the terminal and line discipline state of the terminal that is on its standard output, and then (if successful) chain loads to next-prog with the execvp3 function.
If its standard output is not a terminal, it aborts without attempting to initialize anything.
next-prog may contain its own command line options, which vc-reset-tty will ignore.
vc-reset-tty makes no alteration to process state.
It initializes the terminal by resetting the kernel virtual terminal mode, resetting the line discipline, and then outputting the escape sequences appropriate to the terminal type that initialize the terminal itself.
Kernel virtual terminal mode reset
If the --text-mode command line option is used, vc-reset-tty will use operating-system-specific ioctl2 calls to attempt to switch a kernel virtual terminal to text mode.
Line discipline reset
The line discipline is reset to approximately the same state as would be done by the stty sane command, with several exceptions:
The istrip
option is not set.
8-bit cleanliness is the norm nowadays.
The tostop
option is set, unless the --no-tostop command-line option has been used.
Job control is the norm nowadays.
The iutf8
option is set, unless the --no-utf8 command-line option has been used.
UTF-8 is the norm nowadays, and console-terminal-emulator1 sends UTF-8 input sequences to virtual terminals.
Terminal reset
vc-reset-tty writes terminal escape and control sequences to soft (re-)initialize the terminal state, including tabstops, margins, windows, scrolling mode, and overstrike mode.
If the --hard-reset command line option is used, different escape sequences are written to hard reset the terminal.
It emits these terminal control sequences by spawning console-control-sequence1 with various options including --rows, --columns, and --soft-reset.
For compatibility of the actual control sequences emitted with various terminals and terminal emulators, see the console-control-sequence1 manual.
Use
The major use case for vc-reset-tty is to reset the terminal and line discipline to some known states before printing the login banner (see login-banner1) and running the login1 program.
The use case covers terminals that are "always on" and retain state from one terminal log-on session to the next, as is the case with real terminals (remote and local) and kernel virtual terminals.
vc-reset-tty is, on the other hand, not particularly useful with console-terminal-emulator1, which initializes the line discipline and terminal state itself to much the same state, and exits at hangup; making each log-on session start with an already freshly initialized terminal and line discipline.
The program is much the same as the BSD reset1 command, except that it chain-loads to another command, has a more modern view of what a "sane" line discipline is, does not touch the line discipline's size information, and defaults to a softer reset.
This is behaviour more suitable and streamlined for kernel virtual terminals, at which the command is specifically aimed.
Virtual terminals update the line discipline size themselves, either in response to control sequences that change the terminal size or as part of specialized idiosyncratic resizing utilities.
So there is no need for a VT reset utility to adjust them directly.
(Conversely, real terminals have no access to the line discipline and require that it be expressly kept in synch.)
Real terminals should not normally be sent the hard reset escape sequence, for reasons explained in the console-control-sequence1 manual and DEC VT documentation.
Conversely, the Linux and FreeBSD kernel virtual terminals do not implement the DEC soft reset control sequence.
In line with the general principle of avoiding hard resets, the --hard-reset command line option should only be used with these kernel virtual terminals.
SEE ALSO
stty1
Author
Jonathan de Boyne Pollard