From 9d77d4a158352bae86d52d4b56cb61aff79484f4 Mon Sep 17 00:00:00 2001 From: tholo <> Date: Sun, 22 Jun 1997 20:21:25 +0000 Subject: [PATCH] Make sure we don't get stuck in a loop when trying to clean up stdio --- src/lib/libc/stdlib/abort.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c index 630f377f..4ea8a2ca 100644 --- a/src/lib/libc/stdlib/abort.c +++ b/src/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 @@ -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); /*