1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Don't unblock SIGABRT in abort(3) before calling raise(SIGABRT).

The language in POSIX mentioning overriding blocking or ignoring SIGABRT
refers to the inevitability of exiting by SIGABRT if SIGABRT isn't caught or
if the handler does return.

This implementation of abort(3) implements the standard by raising SIGABRT,
allowing the signal to be caught; and if the signal is blocked or ignored or
the handler returns, then exit_thread(2) forcefully exits the process as if
by SIGABRT.
This commit is contained in:
Jonas 'Sortie' Termansen 2018-09-01 12:42:13 +02:00
parent 918160450f
commit 5837421478

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014 Jonas 'Sortie' Termansen.
* Copyright (c) 2011, 2012, 2013, 2014, 2018 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -17,7 +17,6 @@
* Abnormal process termination.
*/
#include <sys/stat.h>
#include <sys/wait.h>
#include <signal.h>
@ -33,11 +32,6 @@ void abort(void)
#ifdef __is_sortix_libk
libk_abort();
#else
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);