summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortholo <>1997-06-22 20:21:25 +0000
committertholo <>1997-06-22 20:21:25 +0000
commitc3e30a5029a7be2fa6f7521f978a5fcb45134113 (patch)
treed1f8ecb1183c9adf9d359a34cfc285ef6c051f02 /src
parenta95ecf3f30005b6b5d55131cfb166cf8e71e176d (diff)
downloadopenbsd-c3e30a5029a7be2fa6f7521f978a5fcb45134113.tar.gz
openbsd-c3e30a5029a7be2fa6f7521f978a5fcb45134113.tar.bz2
openbsd-c3e30a5029a7be2fa6f7521f978a5fcb45134113.zip
Make sure we don't get stuck in a loop when trying to clean up stdio
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/stdlib/abort.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c
index 630f377f75..4ea8a2ca4b 100644
--- a/src/lib/libc/stdlib/abort.c
+++ b/src/lib/libc/stdlib/abort.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: abort.c,v 1.4 1996/10/25 07:06:37 downsj Exp $"; 35static char *rcsid = "$OpenBSD: abort.c,v 1.5 1997/06/22 20:21:25 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include <signal.h> 38#include <signal.h>
@@ -44,13 +44,9 @@ void (*__cleanup)();
44void 44void
45abort() 45abort()
46{ 46{
47 static int cleanup_called = 0;
47 sigset_t mask; 48 sigset_t mask;
48 49
49 /*
50 * POSIX requires we flush stdio buffers on abort
51 */
52 if (__cleanup)
53 (*__cleanup)();
54 50
55 sigfillset(&mask); 51 sigfillset(&mask);
56 /* 52 /*
@@ -59,6 +55,15 @@ abort()
59 */ 55 */
60 sigdelset(&mask, SIGABRT); 56 sigdelset(&mask, SIGABRT);
61 (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); 57 (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
58
59 /*
60 * POSIX requires we flush stdio buffers on abort
61 */
62 if (cleanup_called == 0 && __cleanup != NULL) {
63 cleanup_called = 1;
64 (*__cleanup)();
65 }
66
62 (void)kill(getpid(), SIGABRT); 67 (void)kill(getpid(), SIGABRT);
63 68
64 /* 69 /*