Browse files

call isatty once instead of twice.

  • Loading branch information...
1 parent 9d15781 commit 86961f5c17d643089654c5599d1fafbb1ce72e6e @jmesmon jmesmon committed with Jan 24, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 io.c
View
5 io.c
@@ -356,12 +356,13 @@ read_passphrase(const char *prompt, char *pass, size_t passlen, time_t timeout)
ssize_t n;
int fd = STDIN_FILENO, r = 0, nready;
struct sigaction act, old_act;
+ int is_tty = isatty(fd);
memset(pass, 0, passlen);
/* If input is being provided by something which is not a terminal, don't
* change the settings. */
- if (isatty(fd)) {
+ if (is_tty) {
printf("%s", prompt);
fflush(stdout);
@@ -404,7 +405,7 @@ read_passphrase(const char *prompt, char *pass, size_t passlen, time_t timeout)
out:
- if (isatty(fd)) {
+ if (is_tty) {
tcsetattr(fd, TCSAFLUSH, &termios_old);
putchar('\n');

0 comments on commit 86961f5

Please sign in to comment.