xref: /csrg-svn/lib/libc/stdlib/abort.c (revision 42633)
121338Sdist /*
224054Skarels  * Copyright (c) 1985 Regents of the University of California.
335301Sbostic  * All rights reserved.
435301Sbostic  *
5*42633Sbostic  * %sccs.include.redist.c%
621338Sdist  */
717866Sralph 
826540Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42633Sbostic static char sccsid[] = "@(#)abort.c	5.10 (Berkeley) 06/01/90";
1035301Sbostic #endif /* LIBC_SCCS and not lint */
1121338Sdist 
1242095Sbostic #include <sys/signal.h>
1342102Sbostic #include <stdlib.h>
1442102Sbostic #include <stddef.h>
1517866Sralph 
1642187Sbostic void
1717866Sralph abort()
1817866Sralph {
1942102Sbostic 	sigset_t mask;
2042102Sbostic 
2142102Sbostic 	sigfillset(&mask);
2242102Sbostic 	/*
2342102Sbostic 	 * don't block SIGABRT to give any handler a chance; we ignore
2442102Sbostic 	 * any errors -- X311J doesn't allow abort to return anyway.
2542102Sbostic 	 */
2642102Sbostic 	sigdelset(&mask, SIGABRT);
2742102Sbostic 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
2842095Sbostic 	(void)kill(getpid(), SIGABRT);
2942102Sbostic 
3042102Sbostic 	/*
3142102Sbostic 	 * if SIGABRT ignored, or caught and the handler returns, do
3242102Sbostic 	 * it again, only harder.
3342102Sbostic 	 */
3438790Skarels 	(void)signal(SIGABRT, SIG_DFL);
3542102Sbostic 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
3638790Skarels 	(void)kill(getpid(), SIGABRT);
3742102Sbostic 	exit(1);
3817866Sralph }
39