mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
[signals] include SIGBUS among fatal signals
This commit is contained in:
parent
cd5c913994
commit
48ee66918a
2
NEWS.md
2
NEWS.md
@ -15,6 +15,8 @@ rearrangements of Notcurses.
|
||||
* Added new functions `notcurses_canpixel()` and `notcurses_osversion()`.
|
||||
* `notcurses_get()` now evaluates its timeout against `CLOCK_MONOTONIC`
|
||||
instead of `CLOCK_REALTIME`.
|
||||
* `SIGBUS` is now included among the signals for which a handler is
|
||||
by default installed.
|
||||
|
||||
* 2.4.7 (2021-10-16)
|
||||
* Features 1, 2, and 8 of the Kitty keyboard protocol are now supported. This
|
||||
|
@ -174,10 +174,10 @@ The following flags are defined:
|
||||
buffer up, eventually preventing Notcurses from processing terminal
|
||||
messages. It will furthermore avoid wasting time processing useless input.
|
||||
|
||||
* **NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS**: A signal handler will usually be installed
|
||||
for **SIGABRT**, **SIGFPE**, **SIGILL**, **SIGINT**, **SIGQUIT**,
|
||||
**SIGSEGV**, and **SIGTERM**, cleaning up the terminal on such exceptions.
|
||||
With this flag, the handler will not be installed.
|
||||
* **NCDIRECT_OPTION_NO_QUIT_SIGHANDLERS**: A signal handler will usually be
|
||||
installed for **SIGABRT**, **SIGBUS**, **SIGFPE**, **SIGILL**, **SIGINT**,
|
||||
**SIGQUIT**, **SIGSEGV**, and **SIGTERM**, cleaning up the terminal on
|
||||
such exceptions. With this flag, the handler will not be installed.
|
||||
|
||||
* **NCDIRECT_OPTION_VERBOSE**: Enable diagnostics to **stderr** at the level of
|
||||
**NCLOGLEVEL_WARNING**.
|
||||
|
@ -127,9 +127,9 @@ zero. The following flags are defined:
|
||||
installed.
|
||||
|
||||
* **NCOPTION_NO_QUIT_SIGHANDLERS**: A signal handler will usually be installed
|
||||
for **SIGABRT**, **SIGFPE**, **SIGILL**, **SIGINT**, **SIGQUIT**,
|
||||
**SIGSEGV**, and **SIGTERM**, cleaning up the terminal on such exceptions.
|
||||
With this flag, the handler will not be installed.
|
||||
for **SIGABRT**, **SIGBUS**, **SIGFPE**, **SIGILL**, **SIGINT**,
|
||||
**SIGQUIT**, **SIGSEGV**, and **SIGTERM**, cleaning up the terminal on such
|
||||
exceptions. With this flag, the handler will not be installed.
|
||||
|
||||
* **NCOPTION_SUPPRESS_BANNERS**: Disables the diagnostics and version
|
||||
information printed on startup, and the performance summary on exit.
|
||||
|
@ -54,6 +54,7 @@ static bool handling_fatals;
|
||||
static struct sigaction old_winch;
|
||||
static struct sigaction old_cont;
|
||||
static struct sigaction old_abrt;
|
||||
static struct sigaction old_bus;
|
||||
static struct sigaction old_fpe;
|
||||
static struct sigaction old_ill;
|
||||
static struct sigaction old_int;
|
||||
@ -94,6 +95,7 @@ int drop_signals(void* nc){
|
||||
}
|
||||
if(handling_fatals){
|
||||
sigaction(SIGABRT, &old_abrt, NULL);
|
||||
sigaction(SIGBUS, &old_bus, NULL);
|
||||
sigaction(SIGFPE, &old_fpe, NULL);
|
||||
sigaction(SIGILL, &old_ill, NULL);
|
||||
sigaction(SIGINT, &old_int, NULL);
|
||||
@ -136,6 +138,7 @@ fatal_handler(int signo, siginfo_t* siginfo, void* v){
|
||||
case SIGINT: invoke_old(&old_int, signo, siginfo, v); break;
|
||||
case SIGILL: invoke_old(&old_ill, signo, siginfo, v); break;
|
||||
case SIGFPE: invoke_old(&old_fpe, signo, siginfo, v); break;
|
||||
case SIGBUS: invoke_old(&old_bus, signo, siginfo, v); break;
|
||||
case SIGABRT: invoke_old(&old_abrt, signo, siginfo, v); break;
|
||||
}
|
||||
raise(signo); // FIXME does this invoke twice? hrmmm
|
||||
@ -180,21 +183,23 @@ int setup_signals(void* vnc, bool no_quit_sigs, bool no_winch_sigs,
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
fatal_callback = handler;
|
||||
sa.sa_sigaction = fatal_handler;
|
||||
sigaddset(&sa.sa_mask, SIGABRT);
|
||||
sigaddset(&sa.sa_mask, SIGBUS);
|
||||
sigaddset(&sa.sa_mask, SIGFPE);
|
||||
sigaddset(&sa.sa_mask, SIGILL);
|
||||
sigaddset(&sa.sa_mask, SIGINT);
|
||||
sigaddset(&sa.sa_mask, SIGQUIT);
|
||||
sigaddset(&sa.sa_mask, SIGSEGV);
|
||||
sigaddset(&sa.sa_mask, SIGABRT);
|
||||
sigaddset(&sa.sa_mask, SIGTERM);
|
||||
sa.sa_flags = SA_SIGINFO | SA_RESETHAND; // don't try fatal signals twice
|
||||
int ret = 0;
|
||||
ret |= sigaction(SIGABRT, &sa, &old_abrt);
|
||||
ret |= sigaction(SIGBUS, &sa, &old_bus);
|
||||
ret |= sigaction(SIGFPE, &sa, &old_fpe);
|
||||
ret |= sigaction(SIGILL, &sa, &old_ill);
|
||||
ret |= sigaction(SIGINT, &sa, &old_int);
|
||||
ret |= sigaction(SIGQUIT, &sa, &old_quit);
|
||||
ret |= sigaction(SIGSEGV, &sa, &old_segv);
|
||||
ret |= sigaction(SIGABRT, &sa, &old_abrt);
|
||||
ret |= sigaction(SIGTERM, &sa, &old_term);
|
||||
if(ret){
|
||||
atomic_store(&signal_nc, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user