diff options
author | Jim Warner <james.warner@comcast.net> | 2012-10-01 10:00:00 -0500 |
---|---|---|
committer | Craig Small <csmall@enc.com.au> | 2012-10-11 21:10:44 +1100 |
commit | edd8aae5bafaeb7c43c1733873cda614ec2cb0c9 (patch) | |
tree | abdfd93aac01ae9ea5e3fa563d93abaad14f4b61 | |
parent | bb6cc9c15927981b874bc7cec1ff46bfa8300271 (diff) | |
download | procps-ng-edd8aae5bafaeb7c43c1733873cda614ec2cb0c9.tar.gz |
top: avoid potential xterm state corruption
To support the cursor navigation keys, after saving
the termios structure top issues 'smkx/keypad_xmit'
during startup. However, some terminals appear to
treat that directive as persistent which leaves a
corrupted tty state after top exit.
This commit reverses the above terminal directive
via 'rmkx/keypad_local' just prior to restoring the
saved termios structure at program end.
For discovering this bug, and providing the 'rmkx'
clue to its solution, thanks to:
Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Jim Warner <james.warner@comcast.net>
-rw-r--r-- | top/top.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -312,6 +312,7 @@ static const char *tg2 (int x, int y) { static void bye_bye (const char *str) NORETURN; static void bye_bye (const char *str) { if (Ttychanged) { + if (keypad_local) putp(keypad_local); tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_original); putp(tg2(0, Screen_rows)); putp(Cap_curs_norm); @@ -923,6 +924,7 @@ static int keyin (int init) { STRLCPY(buf15, fmtmk("\033%s", tOk(key_left))); // next is critical so returned results match bound terminfo keys putp(tOk(keypad_xmit)); + // ( see the converse keypad_local at program end, just in case ) return 0; #undef tOk } |