]> Kevux Git Server - fll/commitdiff
Bugfix: Signal id should be -1 the id should be passed to signalfd().
authorKevin Day <thekevinday@gmail.com>
Thu, 23 Dec 2021 03:07:15 +0000 (21:07 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 23 Dec 2021 03:15:49 +0000 (21:15 -0600)
A file descriptor should be set to -1 and not 0.
The 0 file descriptor is actually valid.

The signalfd() program accepts an id.
It makes sense to pass this along rather than always forcing -1.

22 files changed:
level_0/f_signal/c/signal-common.h
level_0/f_signal/c/signal.c
level_0/f_signal/c/signal.h
level_3/byte_dump/c/private-common.c
level_3/control/c/private-common.c
level_3/fake/c/private-common.c
level_3/firewall/c/private-common.c
level_3/fss_basic_list_read/c/private-common.c
level_3/fss_basic_list_write/c/private-common.c
level_3/fss_basic_read/c/private-common.c
level_3/fss_basic_write/c/private-common.c
level_3/fss_embedded_list_read/c/private-common.c
level_3/fss_embedded_list_write/c/private-common.c
level_3/fss_extended_list_read/c/private-common.c
level_3/fss_extended_list_write/c/private-common.c
level_3/fss_extended_read/c/private-common.c
level_3/fss_extended_write/c/private-common.c
level_3/fss_identify/c/private-common.c
level_3/fss_status_code/c/private-common.c
level_3/iki_read/c/private-common.c
level_3/iki_write/c/private-common.c
level_3/status_code/c/private-common.c

index b9c841520f4ea22f369d27ad036e900e628f6d57..8d3d67dcdb0d3f6ca55984ba598878522c9dc027 100644 (file)
@@ -30,13 +30,13 @@ extern "C" {
     sigset_t set;
   } f_signal_t;
 
-  #define f_signal_t_initialize {0, 0, { 0 } }
+  #define f_signal_t_initialize {0, -1, { 0 } }
 
   #define macro_f_signal_t_initialize(flags, id, set) { flags, id, set }
 
   #define macro_f_signal_t_clear(signal) \
     signal.flags = 0; \
-    signal.id = 0; \
+    signal.id = -1; \
     signal.set[0] = 0;
 #endif // _di_f_signal_t_
 
index 0bdeb856d39df9f69b14eb4dec666c26288c49cb..e2ffaaa80ced42b361dc18a179c966df329296a9 100644 (file)
@@ -35,7 +35,7 @@ extern "C" {
       if (!signal) return F_status_set_error(F_parameter);
     #endif // _di_level_0_parameter_checking_
 
-    int result = signalfd(-1, &signal->set, signal->flags);
+    const int result = signalfd(signal->id, &signal->set, signal->flags);
 
     if (result < 0) {
       if (errno == EINVAL) return F_status_set_error(F_parameter);
index c0563dfd319e80417af6a01d8ce434c3abde8112..62580a2c85ced258db66d2344c9423c6db04e6c6 100644 (file)
@@ -60,6 +60,9 @@ extern "C" {
  * @param signal
  *   The signal settings.
  *
+ *   If signal.id is -1, then a new file descriptor is created.
+ *   Otherwise, signal.id is used as the file descriptor.
+ *
  * @return
  *   F_none on success but no signal found.
  *   F_device (with error bit) if could not mount the internal inode device.
index 15a0a169e57a7963f0829add43adb10df04cdb8c..1c2bf8a4d23b925a3c95218af72dffdb1995eed1 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_byte_dump_signal_received_
   f_status_t byte_dump_signal_received(byte_dump_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 92941dab70a022a66191b661edbe843e0bc4bea3..a32fd1fd5187a1247310a9b5cdee2836b49397c1 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_control_signal_received_
   f_status_t control_signal_received(control_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 3ac996e7869c44d9e17c917fd8f07cf63a7e196d..4ed9784e819d84b365da656a9424dad06470cc46 100644 (file)
@@ -258,7 +258,7 @@ extern "C" {
 #ifndef _di_fake_signal_received_
   f_status_t fake_signal_received(fake_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 07a4227ad55ce2be3da4de9fb3a8802652455a85..ee858fd0f3b8af7a87e6df2fb6d575e1a0650026 100644 (file)
@@ -96,7 +96,7 @@ void firewall_print_error_on_unhandled_for_file(const fl_print_t output, const f
 #ifndef _di_firewall_signal_received_
   f_status_t firewall_signal_received(firewall_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index aa8bfbb72e81815f52a1f3b81dfbad3164d6c412..14ddedda664c23bd58c9ef10ff55f6d1622a0175 100644 (file)
@@ -78,7 +78,7 @@ extern "C" {
 #ifndef _di_fss_basic_list_read_signal_received_
   f_status_t fss_basic_list_read_signal_received(fss_basic_list_read_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 5cea2285783f76fabef64d423415084241ebe2e3..bf468685f259188bf43394f0719f75cdf2eefb14 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_basic_list_write_signal_received_
   f_status_t fss_basic_list_write_signal_received(fss_basic_list_write_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 26d9f3befe217d217ac00068b30e9bc180829649..276e78651788c707c1dd4c00545cbd64ab281dd6 100644 (file)
@@ -77,7 +77,7 @@ extern "C" {
 #ifndef _di_fss_basic_read_signal_received_
   f_status_t fss_basic_read_signal_received(fss_basic_read_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 66cad09c4179b80f9d17654d288f3b273cd8793f..c253bdcd4af50e6ab0ba4d4b0f0847a7613ddb27 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_basic_write_signal_received_
   f_status_t fss_basic_write_signal_received(fss_basic_write_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 68cb82a09404e22761ba822415e5a05a1154aadb..3f211cdb768028cd8344ef0bf7ff49881b4407c4 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_embedded_list_read_signal_received_
   f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index c90e4f9ce47726ff001d03c4ed6952f8de962aab..edbc4bb595e70509870bf0c9c04281744dd91ef2 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_embedded_list_write_signal_received_
   f_status_t fss_embedded_list_write_signal_received(fss_embedded_list_write_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 97e73b0ec74e7ec8ef27224bc6946eb005b940cf..49ff1b5a24ded14ffb9a87cd86562aa5c6939c2b 100644 (file)
@@ -78,7 +78,7 @@ extern "C" {
 #ifndef _di_fss_extended_list_read_signal_received_
   f_status_t fss_extended_list_read_signal_received(fss_extended_list_read_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index af21cd3716d3e5fe950d62a935a2a04da2b8dbe3..b588c361b15663adf45767559c06ff3b0272275a 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_extended_list_write_signal_received_
   f_status_t fss_extended_list_write_signal_received(fss_extended_list_write_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 65b74822ed5d3300d19f0983d11e90ff66b44758..2ca7672e2030ffbe082a22c7f2e9e850971cdd57 100644 (file)
@@ -79,7 +79,7 @@ extern "C" {
 #ifndef _di_fss_extended_read_signal_received_
   f_status_t fss_extended_read_signal_received(fss_extended_read_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index dd095ea7bc0f3a21895e0fd5a66d937cbee28e30..da04e4acc0413dde609833184277760446634a50 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_extended_write_signal_received_
   f_status_t fss_extended_write_signal_received(fss_extended_write_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index dcf1eaab009fd3c4f088bc4cac0f4f3bc61a32d9..81a8d30dd7080dfc776d35e62983ae7b05efeb56 100644 (file)
@@ -35,7 +35,7 @@ extern "C" {
 #ifndef _di_fss_identify_signal_received_
   f_status_t fss_identify_signal_received(fss_identify_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 3d12c1e407ac4d93ef8916200ede63c5c158ae79..b1b0e67c2b36cdad897c2b544b945ff6a808ed70 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_fss_status_code_signal_received_
   f_status_t fss_status_code_signal_received(fss_status_code_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index dd4af45bf30446126362926d23e2f6c3678b15f0..1a135e47d554071ee1f8d055042114a52eba135d 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_iki_read_signal_received_
   f_status_t iki_read_signal_received(iki_read_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 3eb18806caa7d132472c619ab410e63cafa609ba..8083e83c0f01a2be205689bb9e5ce50e6052bf83 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_iki_write_signal_received_
   f_status_t iki_write_signal_received(iki_write_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }
 
index 132f650a343f9f8fd3232e7a6c46924fe0aa2fc7..55b9867af56caeb5c690663b119f0ca99c2855f5 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #ifndef _di_status_code_signal_received_
   f_status_t status_code_signal_received(status_code_main_t * const main) {
 
-    if (!main->signal.id) {
+    if (main->signal.id == -1) {
       return F_false;
     }