xref: /original-bsd/lib/libc/stdlib/abort.c (revision f43fc9d7)
1 /*
2  * Copyright (c) 1985 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)abort.c	5.10 (Berkeley) 06/01/90";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/signal.h>
13 #include <stdlib.h>
14 #include <stddef.h>
15 
16 void
17 abort()
18 {
19 	sigset_t mask;
20 
21 	sigfillset(&mask);
22 	/*
23 	 * don't block SIGABRT to give any handler a chance; we ignore
24 	 * any errors -- X311J doesn't allow abort to return anyway.
25 	 */
26 	sigdelset(&mask, SIGABRT);
27 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
28 	(void)kill(getpid(), SIGABRT);
29 
30 	/*
31 	 * if SIGABRT ignored, or caught and the handler returns, do
32 	 * it again, only harder.
33 	 */
34 	(void)signal(SIGABRT, SIG_DFL);
35 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
36 	(void)kill(getpid(), SIGABRT);
37 	exit(1);
38 }
39