From a0963c8ae93d2c70d61bb4ed34c46f3497b66690 Mon Sep 17 00:00:00 2001 From: Benjamin Pereto Date: Wed, 14 Jun 2017 09:13:04 +0200 Subject: FIX: save old termio structure properly --- bin/ykfde.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ykfde.c b/bin/ykfde.c index cc69636..56e2e0c 100644 --- a/bin/ykfde.c +++ b/bin/ykfde.c @@ -69,10 +69,10 @@ char * ask_secret(const char * text) { /* get terminal properties */ if (tcgetattr(STDIN_FILENO, &tp) < 0) { onTerminal = false; + } else { tp_save = tp; } - /* disable echo on terminal */ if (onTerminal) { tp.c_lflag &= ~ECHO; @@ -92,7 +92,7 @@ char * ask_secret(const char * text) { /* restore terminal */ if (tcsetattr(STDIN_FILENO, TCSANOW, &tp_save) < 0) { - fprintf(stderr, "Failed setting terminal attributes.\n"); + fprintf(stderr, "Failed to restore terminal attributes.\n"); free(factor); return NULL; } -- cgit v1.2.3-70-g09d2