]> Kevux Git Server - fll/commitdiff
Update: The standard program setup should explicitly unblock all signals other than...
authorKevin Day <thekevinday@gmail.com>
Thu, 21 Jul 2022 01:40:14 +0000 (20:40 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 21 Jul 2022 01:40:55 +0000 (20:40 -0500)
The fll_program_standard_setup() function blocks certain signals.
Do not assume all other signals are unblocked.
Explicitly unblock all other signals.

level_2/fll_program/c/program.c
level_2/fll_program/c/program.h

index 340b5dd586be89ac03ce1d88ab9be99dd5d255b6..54575535c2840696db1f98196b552a87ad90b411 100644 (file)
@@ -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;
index 1946cf18c25aa0130745b64a40e246e4f3707041..bdea76a7b83b83036ea6015416f0cd96675ca197 100644 (file)
@@ -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);