Skip to content

Commit

Permalink
FIX: save old termio structure properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Pereto committed Jun 14, 2017
1 parent b5ad306 commit a0963c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bin/ykfde.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit a0963c8

Please sign in to comment.