xref: /csrg-svn/lib/libc/stdlib/abort.c (revision 42187)
121338Sdist /*
224054Skarels  * Copyright (c) 1985 Regents of the University of California.
335301Sbostic  * All rights reserved.
435301Sbostic  *
535301Sbostic  * Redistribution and use in source and binary forms are permitted
635301Sbostic  * provided that the above copyright notice and this paragraph are
735301Sbostic  * duplicated in all such forms and that any documentation,
835301Sbostic  * advertising materials, and other materials related to such
935301Sbostic  * distribution and use acknowledge that the software was developed
1035301Sbostic  * by the University of California, Berkeley.  The name of the
1135301Sbostic  * University may not be used to endorse or promote products derived
1235301Sbostic  * from this software without specific prior written permission.
1335301Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1435301Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1535301Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1621338Sdist  */
1717866Sralph 
1826540Sdonn #if defined(LIBC_SCCS) && !defined(lint)
19*42187Sbostic static char sccsid[] = "@(#)abort.c	5.9 (Berkeley) 05/17/90";
2035301Sbostic #endif /* LIBC_SCCS and not lint */
2121338Sdist 
2242095Sbostic #include <sys/signal.h>
2342102Sbostic #include <stdlib.h>
2442102Sbostic #include <stddef.h>
2517866Sralph 
26*42187Sbostic void
2717866Sralph abort()
2817866Sralph {
2942102Sbostic 	sigset_t mask;
3042102Sbostic 
3142102Sbostic 	sigfillset(&mask);
3242102Sbostic 	/*
3342102Sbostic 	 * don't block SIGABRT to give any handler a chance; we ignore
3442102Sbostic 	 * any errors -- X311J doesn't allow abort to return anyway.
3542102Sbostic 	 */
3642102Sbostic 	sigdelset(&mask, SIGABRT);
3742102Sbostic 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
3842095Sbostic 	(void)kill(getpid(), SIGABRT);
3942102Sbostic 
4042102Sbostic 	/*
4142102Sbostic 	 * if SIGABRT ignored, or caught and the handler returns, do
4242102Sbostic 	 * it again, only harder.
4342102Sbostic 	 */
4438790Skarels 	(void)signal(SIGABRT, SIG_DFL);
4542102Sbostic 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
4638790Skarels 	(void)kill(getpid(), SIGABRT);
4742102Sbostic 	exit(1);
4817866Sralph }
49