Bug 90524 - reset(1) doesn't fully restore terminal state
Summary: reset(1) doesn't fully restore terminal state
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-17 02:00 UTC by yuri
Modified: 2018-02-23 20:09 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yuri 2005-12-17 02:00:09 UTC
If I kill vim (ex. kill -9) key mapping changes and backspace key causes
printing of ^? instead of removing of the current character in terminal.

'reset' command doesn't restore this either. so it's no way to restore
original setting besides of running the command 'stty erase ^?'

Originally 'stty -a' reports:
-----------begin------------------------
speed 38400 baud; 42 rows; 189 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
        -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
        brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
        lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
        status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;
-------------end------------------------

After killing vim and running 'reset' 'stty -a' reports:
-----------begin------------------------
speed 38400 baud; 42 rows; 189 columns;
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
        -extproc
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff -ixany imaxbel -ignbrk
        brkint -inpck ignpar -parmrk
oflags: opost onlcr -ocrnl oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^@; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^H; erase2 = ^H; intr = ^C; kill = ^U;
        lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
        status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;
-------------end------------------------

because 'erase = ^H' particularly backspace key is disrupted.

Fix: 

N/A
How-To-Repeat: see full description
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:10 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Fernando Apesteguía freebsd_committer freebsd_triage 2018-02-23 20:09:32 UTC
Is this really a bug?

According to the man page for teset(1), when invoked as reset, tset does several things before initializing the terminal as tset. If the -m option is not passed (as in this case), then tset tries to _guess_ the terminal type that is being used. As I understand there is no guarantee that this guess will be a perfect match for all the terminal options.

Additionally, reset -e ^? ensures the correct key binding for the erase character after the initialization has been completed (in the case of the reporter).