xref: /csrg-svn/lib/libc/stdlib/abort.c (revision 46599)
121338Sdist /*
224054Skarels  * Copyright (c) 1985 Regents of the University of California.
335301Sbostic  * All rights reserved.
435301Sbostic  *
542633Sbostic  * %sccs.include.redist.c%
621338Sdist  */
717866Sralph 
826540Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*46599Sdonn static char sccsid[] = "@(#)abort.c	5.11 (Berkeley) 02/23/91";
1035301Sbostic #endif /* LIBC_SCCS and not lint */
1121338Sdist 
1242095Sbostic #include <sys/signal.h>
1342102Sbostic #include <stdlib.h>
1442102Sbostic #include <stddef.h>
15*46599Sdonn #include <unistd.h>
1617866Sralph 
1742187Sbostic void
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