summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/abort.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib/abort.c')
-rw-r--r--lib/libc/stdlib/abort.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c
index e56e7e9..4fd34dc 100644
--- a/lib/libc/stdlib/abort.c
+++ b/lib/libc/stdlib/abort.c
@@ -35,31 +35,52 @@
static char sccsid[] = "@(#)abort.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#include <sys/signal.h>
+#include <signal.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+#endif
+
+void (*__cleanup)();
void
abort()
{
sigset_t mask;
+ /*
+ * POSIX requires we flush stdio buffers on abort
+ */
+ if (__cleanup)
+ (*__cleanup)();
+
sigfillset(&mask);
/*
* don't block SIGABRT to give any handler a chance; we ignore
* any errors -- X311J doesn't allow abort to return anyway.
*/
sigdelset(&mask, SIGABRT);
+#ifdef _THREAD_SAFE
+ (void) _thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+#else
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+#endif
(void)kill(getpid(), SIGABRT);
/*
* if SIGABRT ignored, or caught and the handler returns, do
* it again, only harder.
*/
+#ifdef _THREAD_SAFE
+ (void) _thread_sys_signal(SIGABRT, SIG_DFL);
+ (void) _thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+#else
(void)signal(SIGABRT, SIG_DFL);
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
+#endif
(void)kill(getpid(), SIGABRT);
exit(1);
}
OpenPOWER on IntegriCloud