summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/abort.c
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1997-06-22 20:21:26 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1997-06-22 20:21:26 +0000
commit81b89247d5d68e37eda1ce505c897d3a4ca1e1d0 (patch)
treea811ed7235724e85107f552e1dd377be82379698 /lib/libc/stdlib/abort.c
parent80ecbf94418e357f589bf7366b80f8c7b605793b (diff)
Make sure we don't get stuck in a loop when trying to clean up stdio
Diffstat (limited to 'lib/libc/stdlib/abort.c')
-rw-r--r--lib/libc/stdlib/abort.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index 630f377f75e..4ea8a2ca4b7 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: abort.c,v 1.4 1996/10/25 07:06:37 downsj Exp $";
+static char *rcsid = "$OpenBSD: abort.c,v 1.5 1997/06/22 20:21:25 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
#include <signal.h>
@@ -44,13 +44,9 @@ void (*__cleanup)();
void
abort()
{
+ static int cleanup_called = 0;
sigset_t mask;
- /*
- * POSIX requires we flush stdio buffers on abort
- */
- if (__cleanup)
- (*__cleanup)();
sigfillset(&mask);
/*
@@ -59,6 +55,15 @@ abort()
*/
sigdelset(&mask, SIGABRT);
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+
+ /*
+ * POSIX requires we flush stdio buffers on abort
+ */
+ if (cleanup_called == 0 && __cleanup != NULL) {
+ cleanup_called = 1;
+ (*__cleanup)();
+ }
+
(void)kill(getpid(), SIGABRT);
/*