aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-08-30 09:10:12 +0000
committerUlrich Drepper <drepper@redhat.com>2003-08-30 09:10:12 +0000
commitcdbfa9f89fa7ccba5f573facbd0a2322e1a6fcb8 (patch)
tree2b5f5f3cd66ae759cbecac788f3571c6a5dd3599 /misc
parent048466f6148f6d72994eeb234f435fd351e24559 (diff)
downloadglibc-cdbfa9f89fa7ccba5f573facbd0a2322e1a6fcb8.tar
glibc-cdbfa9f89fa7ccba5f573facbd0a2322e1a6fcb8.tar.gz
glibc-cdbfa9f89fa7ccba5f573facbd0a2322e1a6fcb8.tar.bz2
glibc-cdbfa9f89fa7ccba5f573facbd0a2322e1a6fcb8.zip
Update.
* misc/Makefile (CFLAGS-getpass.c): Add -fexceptions. * misc/getpass.c (getpass): Add cleanup handler to ensure the stream is closed even if the thread is canceled. (call_fclose): New function. * posix/unistd.h: Remove __THROW from getpass prorotype. * posix/Makefile (CFLAGS-getopt.c): Add -fexceptions. * signal/signal.h (psignal): Remove __THROW. * stdio-common/Makefile (CFLAGS-psignal.c): Add -fexceptions.
Diffstat (limited to 'misc')
-rw-r--r--misc/Makefile1
-rw-r--r--misc/getpass.c24
2 files changed, 19 insertions, 6 deletions
diff --git a/misc/Makefile b/misc/Makefile
index 570ff081a1..5c93e43ec6 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -83,6 +83,7 @@ CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-usleep.c = -fexceptions
CFLAGS-syslog.c = -fexceptions
CFLAGS-error.c = -fexceptions
+CFLAGS-getpass.c = -fexceptions
include ../Rules
diff --git a/misc/getpass.c b/misc/getpass.c
index e5483f9e50..70562e54af 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,93,94,95,96,97,98,99,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1992-1999, 2001, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,11 +21,10 @@
#include <termios.h>
#include <unistd.h>
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# define flockfile(s) _IO_flockfile (s)
-# define funlockfile(s) _IO_funlockfile (s)
-#endif
+#include <wchar.h>
+#define flockfile(s) _IO_flockfile (s)
+#define funlockfile(s) _IO_funlockfile (s)
+#include <bits/libc-lock.h>
/* It is desirable to use this bit on systems that have it.
The only bit of terminal state we want to twiddle is echoing, which is
@@ -36,6 +35,13 @@
#define TCSASOFT 0
#endif
+static void
+call_fclose (void *arg)
+{
+ if (arg != NULL)
+ fclose (arg);
+}
+
char *
getpass (prompt)
const char *prompt;
@@ -64,6 +70,10 @@ getpass (prompt)
out = in;
}
+ /* Make sure the stream we opened is closed even if the thread is
+ canceled. */
+ __libc_cleanup_push (call_fclose, in == out ? in : NULL);
+
flockfile (out);
/* Turn echoing off if it is on now. */
@@ -117,6 +127,8 @@ getpass (prompt)
funlockfile (out);
+ __libc_cleanup_pop (0);
+
if (in != stdin)
/* We opened the terminal; now close it. */
fclose (in);