summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 27fe085)
raw | patch | inline | side by side (parent: 27fe085)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 11 Dec 2014 08:45:41 +0000 (09:45 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 11 Dec 2014 08:45:41 +0000 (09:45 +0100) |
Don't record the "old" settings on each call to rawmode since we do that a lot
of times. Also, don't use up all atexit handler slots this way.
of times. Also, don't use up all atexit handler slots this way.
src/tools/sysdb/input.c | patch | blob | history |
index 55a074cd3863f8a39fa947a7f96cba2d8822488f..9ed11eddd0e26309fab0bbda7333495ae86bd37c 100644 (file)
--- a/src/tools/sysdb/input.c
+++ b/src/tools/sysdb/input.c
*/
static struct termios orig_term_attrs;
+static bool have_orig_term_attrs;
/*
* private helper functions
{
struct termios attrs;
+ if (! have_orig_term_attrs) {
+ memset(&orig_term_attrs, 0, sizeof(orig_term_attrs));
+ tcgetattr(STDIN_FILENO, &orig_term_attrs);
+ atexit(reset_term_attrs);
+ have_orig_term_attrs = 1;
+ }
+
/* setup terminal to operate in non-canonical mode
* and single character input */
- memset(&orig_term_attrs, 0, sizeof(orig_term_attrs));
- tcgetattr(STDIN_FILENO, &orig_term_attrs);
- atexit(reset_term_attrs);
-
memset(&attrs, 0, sizeof(attrs));
tcgetattr(STDIN_FILENO, &attrs);
attrs.c_lflag &= (tcflag_t)(~ICANON);