diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libc/stdlib/abort.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c index c298e016b4..2430c124f9 100644 --- a/src/lib/libc/stdlib/abort.c +++ b/src/lib/libc/stdlib/abort.c | |||
| @@ -10,11 +10,7 @@ | |||
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the | 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. | 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. All advertising materials mentioning features or use of this software | 13 | * 3. Neither the name of the University nor the names of its contributors |
| 14 | * must display the following acknowledgement: | ||
| 15 | * This product includes software developed by the University of | ||
| 16 | * California, Berkeley and its contributors. | ||
| 17 | * 4. Neither the name of the University nor the names of its contributors | ||
| 18 | * may be used to endorse or promote products derived from this software | 14 | * may be used to endorse or promote products derived from this software |
| 19 | * without specific prior written permission. | 15 | * without specific prior written permission. |
| 20 | * | 16 | * |
| @@ -32,26 +28,43 @@ | |||
| 32 | */ | 28 | */ |
| 33 | 29 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 30 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | /*static char *sccsid = "from: @(#)abort.c 5.11 (Berkeley) 2/23/91";*/ | 31 | static char *rcsid = "$OpenBSD: abort.c,v 1.13 2004/01/20 19:35:17 millert Exp $"; |
| 36 | static 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 */ | 32 | #endif /* LIBC_SCCS and not lint */ |
| 38 | 33 | ||
| 39 | #include <signal.h> | 34 | #include <signal.h> |
| 40 | #include <stdlib.h> | 35 | #include <stdlib.h> |
| 41 | #include <unistd.h> | 36 | #include <unistd.h> |
| 37 | #include "thread_private.h" | ||
| 38 | #include "atexit.h" | ||
| 42 | 39 | ||
| 43 | void | 40 | void |
| 44 | abort() | 41 | abort(void) |
| 45 | { | 42 | { |
| 43 | struct atexit *p = __atexit; | ||
| 44 | static int cleanup_called = 0; | ||
| 46 | sigset_t mask; | 45 | sigset_t mask; |
| 47 | 46 | ||
| 47 | |||
| 48 | sigfillset(&mask); | 48 | sigfillset(&mask); |
| 49 | /* | 49 | /* |
| 50 | * don't block SIGABRT to give any handler a chance; we ignore | 50 | * don't block SIGABRT to give any handler a chance; we ignore |
| 51 | * any errors -- X311J doesn't allow abort to return anyway. | 51 | * any errors -- X311J doesn't allow abort to return anyway. |
| 52 | */ | 52 | */ |
| 53 | sigdelset(&mask, SIGABRT); | 53 | sigdelset(&mask, SIGABRT); |
| 54 | (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); | 54 | (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); |
| 55 | |||
| 56 | /* | ||
| 57 | * POSIX requires we flush stdio buffers on abort | ||
| 58 | */ | ||
| 59 | if (cleanup_called == 0) { | ||
| 60 | while (p != NULL && p->next != NULL) | ||
| 61 | p = p->next; | ||
| 62 | if (p != NULL && p->fns[0] != NULL) { | ||
| 63 | cleanup_called = 1; | ||
| 64 | (*p->fns[0])(); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 55 | (void)kill(getpid(), SIGABRT); | 68 | (void)kill(getpid(), SIGABRT); |
| 56 | 69 | ||
| 57 | /* | 70 | /* |
| @@ -59,7 +72,7 @@ abort() | |||
| 59 | * it again, only harder. | 72 | * it again, only harder. |
| 60 | */ | 73 | */ |
| 61 | (void)signal(SIGABRT, SIG_DFL); | 74 | (void)signal(SIGABRT, SIG_DFL); |
| 62 | (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); | 75 | (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); |
| 63 | (void)kill(getpid(), SIGABRT); | 76 | (void)kill(getpid(), SIGABRT); |
| 64 | exit(1); | 77 | _exit(1); |
| 65 | } | 78 | } |
