xref: /csrg-svn/lib/libc/stdlib/abort.c (revision 61180)
121338Sdist /*
2*61180Sbostic  * Copyright (c) 1985, 1993
3*61180Sbostic  *	The Regents of the University of California.  All rights reserved.
435301Sbostic  *
542633Sbostic  * %sccs.include.redist.c%
621338Sdist  */
717866Sralph 
826540Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*61180Sbostic static char sccsid[] = "@(#)abort.c	8.1 (Berkeley) 06/04/93";
1035301Sbostic #endif /* LIBC_SCCS and not lint */
1121338Sdist 
1242095Sbostic #include <sys/signal.h>
1342102Sbostic #include <stdlib.h>
1442102Sbostic #include <stddef.h>
1546599Sdonn #include <unistd.h>
1617866Sralph 
1742187Sbostic void
abort()1817866Sralph abort()
1917866Sralph {
2042102Sbostic 	sigset_t mask;
2142102Sbostic 
2242102Sbostic 	sigfillset(&mask);
2342102Sbostic 	/*
2442102Sbostic 	 * don't block SIGABRT to give any handler a chance; we ignore
2542102Sbostic 	 * any errors -- X311J doesn't allow abort to return anyway.
2642102Sbostic 	 */
2742102Sbostic 	sigdelset(&mask, SIGABRT);
2842102Sbostic 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
2942095Sbostic 	(void)kill(getpid(), SIGABRT);
3042102Sbostic 
3142102Sbostic 	/*
3242102Sbostic 	 * if SIGABRT ignored, or caught and the handler returns, do
3342102Sbostic 	 * it again, only harder.
3442102Sbostic 	 */
3538790Skarels 	(void)signal(SIGABRT, SIG_DFL);
3642102Sbostic 	(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
3738790Skarels 	(void)kill(getpid(), SIGABRT);
3842102Sbostic 	exit(1);
3917866Sralph }
40