Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

call isatty once instead of twice.

  • Loading branch information...
commit 86961f5c17d643089654c5599d1fafbb1ce72e6e 1 parent 9d15781
@jmesmon jmesmon authored committed
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');
Please sign in to comment.
Something went wrong with that request. Please try again.