2012-09-06 20:30:09 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2013-08-04 18:24:59 +00:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
|
2012-09-06 20:30:09 +00:00
|
|
|
|
2013-07-10 13:26:01 +00:00
|
|
|
This file is part of the Sortix C Library.
|
2012-09-06 20:30:09 +00:00
|
|
|
|
2013-07-10 13:26:01 +00:00
|
|
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
2012-09-06 20:30:09 +00:00
|
|
|
|
2013-07-10 13:26:01 +00:00
|
|
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2012-09-06 20:30:09 +00:00
|
|
|
|
2013-07-10 13:26:01 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
2012-09-06 20:30:09 +00:00
|
|
|
|
2016-02-28 11:11:02 +00:00
|
|
|
stdlib/abort.c
|
2013-07-10 13:26:01 +00:00
|
|
|
Abnormal process termination.
|
2012-09-06 20:30:09 +00:00
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2013-01-06 15:52:00 +00:00
|
|
|
#include <sys/stat.h>
|
2013-08-04 18:24:59 +00:00
|
|
|
#include <sys/wait.h>
|
2013-01-06 15:52:00 +00:00
|
|
|
|
2013-08-04 18:24:59 +00:00
|
|
|
#include <signal.h>
|
2012-09-06 20:30:09 +00:00
|
|
|
#include <stdlib.h>
|
2013-08-04 18:24:59 +00:00
|
|
|
#include <unistd.h>
|
2012-09-06 20:30:09 +00:00
|
|
|
|
2016-02-28 11:11:02 +00:00
|
|
|
#ifdef __is_sortix_libk
|
|
|
|
#include <libk.h>
|
|
|
|
#endif
|
2013-08-19 22:45:03 +00:00
|
|
|
|
2016-02-28 11:11:02 +00:00
|
|
|
void abort(void)
|
2012-09-06 20:30:09 +00:00
|
|
|
{
|
2016-02-28 11:11:02 +00:00
|
|
|
#ifdef __is_sortix_libk
|
|
|
|
libk_abort();
|
|
|
|
#else
|
2013-08-04 18:24:59 +00:00
|
|
|
sigset_t set_of_sigabrt;
|
|
|
|
sigemptyset(&set_of_sigabrt);
|
|
|
|
sigaddset(&set_of_sigabrt, SIGABRT);
|
|
|
|
sigprocmask(SIG_UNBLOCK, &set_of_sigabrt, NULL);
|
|
|
|
|
|
|
|
raise(SIGABRT);
|
|
|
|
|
|
|
|
int exit_code = WCONSTRUCT(WNATURE_SIGNALED, 128 + SIGABRT, SIGABRT);
|
|
|
|
int exit_flags = EXIT_THREAD_PROCESS | EXIT_THREAD_DUMP_CORE;
|
|
|
|
exit_thread(exit_code, exit_flags, NULL);
|
|
|
|
|
|
|
|
__builtin_unreachable();
|
2013-08-19 22:45:03 +00:00
|
|
|
#endif
|
2016-02-28 11:11:02 +00:00
|
|
|
}
|