summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/abort.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/abort.c')
-rw-r--r--src/lib/libc/stdlib/abort.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c
index c298e016b4..a833a1a8b7 100644
--- a/src/lib/libc/stdlib/abort.c
+++ b/src/lib/libc/stdlib/abort.c
@@ -32,26 +32,43 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35/*static char *sccsid = "from: @(#)abort.c 5.11 (Berkeley) 2/23/91";*/ 35static char *rcsid = "$OpenBSD: abort.c,v 1.11 2002/11/05 22:19:55 marc Exp $";
36static char *rcsid = "$Id: abort.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $";
37#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
38 37
39#include <signal.h> 38#include <signal.h>
40#include <stdlib.h> 39#include <stdlib.h>
41#include <unistd.h> 40#include <unistd.h>
41#include "thread_private.h"
42#include "atexit.h"
42 43
43void 44void
44abort() 45abort()
45{ 46{
47 struct atexit *p = __atexit;
48 static int cleanup_called = 0;
46 sigset_t mask; 49 sigset_t mask;
47 50
51
48 sigfillset(&mask); 52 sigfillset(&mask);
49 /* 53 /*
50 * don't block SIGABRT to give any handler a chance; we ignore 54 * don't block SIGABRT to give any handler a chance; we ignore
51 * any errors -- X311J doesn't allow abort to return anyway. 55 * any errors -- X311J doesn't allow abort to return anyway.
52 */ 56 */
53 sigdelset(&mask, SIGABRT); 57 sigdelset(&mask, SIGABRT);
54 (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); 58 (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
59
60 /*
61 * POSIX requires we flush stdio buffers on abort
62 */
63 if (cleanup_called == 0) {
64 while (p != NULL && p->next != NULL)
65 p = p->next;
66 if (p != NULL && p->fns[0] != NULL) {
67 cleanup_called = 1;
68 (*p->fns[0])();
69 }
70 }
71
55 (void)kill(getpid(), SIGABRT); 72 (void)kill(getpid(), SIGABRT);
56 73
57 /* 74 /*
@@ -59,7 +76,7 @@ abort()
59 * it again, only harder. 76 * it again, only harder.
60 */ 77 */
61 (void)signal(SIGABRT, SIG_DFL); 78 (void)signal(SIGABRT, SIG_DFL);
62 (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); 79 (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
63 (void)kill(getpid(), SIGABRT); 80 (void)kill(getpid(), SIGABRT);
64 exit(1); 81 exit(1);
65} 82}