summaryrefslogtreecommitdiff
path: root/libc/unistd
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-04-09 17:00:04 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-04-09 17:00:04 +0000
commit6fe5b769d6e013febf722788cb890c3af9701a02 (patch)
tree7de8ab8bcda3e4a7f80c2e1b473f2dd779faa4df /libc/unistd
parentc0c5714a11fe01407658ba7a5dd2513f626c6b2c (diff)
Only set no buffering if we opened the file. Also, don't bother restoring
buffering since we will close the file in that case anyway.
Diffstat (limited to 'libc/unistd')
-rw-r--r--libc/unistd/getpass.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c
index 8ebc985df..ac2159036 100644
--- a/libc/unistd/getpass.c
+++ b/libc/unistd/getpass.c
@@ -63,8 +63,11 @@ getpass (prompt)
/* Tricky, tricky. */
t.c_lflag &= ~(ECHO|ISIG);
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0);
- /* Disable buffering for input FILE to prevent the buffering from flushing. */
- setvbuf(in, NULL, _IOLBF, 0);
+ if (in != stdin) {
+ /* Disable buffering for read/write FILE to prevent problems with
+ * fseek and buffering for read/write auto-transitioning. */
+ setvbuf(in, NULL, _IONBF, 0);
+ }
}
else
tty_changed = 0;
@@ -93,8 +96,6 @@ getpass (prompt)
/* Restore the original setting. */
if (tty_changed) {
(void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
- /* Re-enable buffering. */
- setlinebuf(in);
}
if (in != stdin)