Skip to content

Commit

Permalink
usability: dont crap the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
comotion committed Mar 2, 2010
1 parent 3ced692 commit 4f3a5bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "configuration.h"
#include "general.h"
#include "gpg.h"
#include <termios.h>
#include "interface_cli.h"
#include "interface_gui.h"
#include "interface_keys.h"
Expand All @@ -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);
}

/* #############################################################################
*
Expand All @@ -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); }

Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions interface_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ void cliEchoOff(void)
*/
void cliEchoOn(void)
{
if(terminalsettings.c_lflag){
tcsetattr(0, TCSANOW, &terminalsettings);
}
}


/* #############################################################################
Expand Down
2 changes: 1 addition & 1 deletion options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};
Expand Down

0 comments on commit 4f3a5bf

Please sign in to comment.