From: Kevin Day Date: Thu, 21 Jul 2022 01:40:14 +0000 (-0500) Subject: Update: The standard program setup should explicitly unblock all signals other than... X-Git-Tag: 0.6.0~31 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=8200a645864d18724f3bb3c855a7e50ac989da3c;p=fll Update: The standard program setup should explicitly unblock all signals other than the default. The fll_program_standard_setup() function blocks certain signals. Do not assume all other signals are unblocked. Explicitly unblock all other signals. --- diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 340b5dd..5457553 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -327,17 +327,32 @@ extern "C" { f_signal_set_add(F_signal_termination, &signal->set); f_status_t status = f_signal_mask(SIG_BLOCK, &signal->set, 0); + if (F_status_is_error(status)) return status; - if (F_status_is_error_not(status)) { - status = f_signal_open(signal); + status = f_signal_open(signal); - // If there is an error opening a signal descriptor, then do not handle signals. - if (F_status_is_error(status)) { - f_signal_mask(SIG_UNBLOCK, &signal->set, 0); - f_signal_close(signal); - } + // If there is an error opening a signal descriptor, then do not handle signals. + if (F_status_is_error(status)) { + f_signal_mask(SIG_UNBLOCK, &signal->set, 0); + f_signal_close(signal); + + return status; } + // Unblock all other signals. + sigset_t set; + + memset(&set, 0, sizeof(sigset_t)); + + f_signal_set_fill(&signal->set); + f_signal_set_delete(F_signal_abort, &signal->set); + f_signal_set_delete(F_signal_broken_pipe, &signal->set); + f_signal_set_delete(F_signal_hangup, &signal->set); + f_signal_set_delete(F_signal_interrupt, &signal->set); + f_signal_set_delete(F_signal_quit, &signal->set); + f_signal_set_delete(F_signal_termination, &signal->set); + + status = f_signal_mask(SIG_UNBLOCK, &set, 0); if (F_status_is_error(status)) return status; return F_none; diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index 1946cf1..bdea76a 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -419,6 +419,10 @@ extern "C" { * * @see f_signal_mask() * @see f_signal_open() + * @see f_signal_set_add() + * @see f_signal_set_delete() + * @see f_signal_set_empty() + * @see f_signal_set_fill() */ #ifndef _di_fll_program_standard_setup_ extern f_status_t fll_program_standard_setup(f_signal_t * const signal);