From 4f3a5bf8224dbfb3dc3528bc95c724ea167c233e Mon Sep 17 00:00:00 2001 From: Kacper Wysocki Date: Tue, 2 Mar 2010 11:35:36 +0100 Subject: [PATCH] usability: dont crap the terminal --- cpm.c | 14 ++++++++++++++ interface_cli.c | 2 ++ options.c | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cpm.c b/cpm.c index 3446165..5553de6 100644 --- a/cpm.c +++ b/cpm.c @@ -28,6 +28,7 @@ #include "configuration.h" #include "general.h" #include "gpg.h" +#include #include "interface_cli.h" #include "interface_gui.h" #include "interface_keys.h" @@ -50,6 +51,15 @@ RETSIGTYPE sighandler(int signum); void testMemset(void); #endif +static struct termios tcsaved; +void savetermios(void) +{ + tcgetattr(0, &tcsaved); +} +void restoretermios(void) +{ + tcsetattr(0, TCSANOW, &tcsaved); +} /* ############################################################################# * @@ -71,6 +81,8 @@ int main(int argc, char **argv) int testrun = 0; #endif + savetermios(); + if (initSecurity(&max_mem_lock, &memory_safe, &ptrace_safe, &memlock_limit)) { exit(1); } @@ -267,7 +279,9 @@ RETSIGTYPE sighandler(int signum) if (signum == SIGINT || signum == SIGTERM) { /* we have to quit right away */ + fprintf(stderr,"\nquitting on signal\n"); fileLockRemove(&dummy); + restoretermios(); _exit(1); } } diff --git a/interface_cli.c b/interface_cli.c index 26b44a7..aa607fa 100644 --- a/interface_cli.c +++ b/interface_cli.c @@ -127,8 +127,10 @@ void cliEchoOff(void) */ void cliEchoOn(void) { + if(terminalsettings.c_lflag){ tcsetattr(0, TCSANOW, &terminalsettings); } + } /* ############################################################################# diff --git a/options.c b/options.c index 7b75a10..66501a7 100644 --- a/options.c +++ b/options.c @@ -176,7 +176,7 @@ int getOptions(int argc, char **argv) { "regex", no_argument, 0, 0 }, /* 10 */ { "regular", no_argument, 0, 0 }, /* 11 */ { "security", no_argument, 0, 0 }, /* 12 */ - { "testrun", optional_argument, 0, 0 }, /* 13 */ + { "testrun", required_argument, 0, 0 }, /* 13 */ { "version", no_argument, 0, 0 }, /* 14 */ { 0, 0, 0, 0 } };