]> Kevux Git Server - fll/commitdiff
Update: Improve pid file handling logic.
authorKevin Day <thekevinday@gmail.com>
Wed, 29 Sep 2021 00:37:51 +0000 (19:37 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 29 Sep 2021 00:37:51 +0000 (19:37 -0500)
I had forgotten that this is already optional.
Change the design to detect when pid file is explicitly disabled (passing an empty string to "--pid").
This avoids the need for the process_pid variable.

level_3/controller/c/controller.c
level_3/controller/c/controller.h
level_3/controller/c/main.c
level_3/controller/c/private-controller.c

index 87404528c879518c1809beaa39bbe85852411c41..cde98f05d209c527ba80ead0b970aaf7f5b885ba 100644 (file)
@@ -240,12 +240,12 @@ extern "C" {
           }
         }
         else {
-          main->process_pid = F_false;
+          setting.path_pid.used = 0;
         }
       }
     }
 
-    if (F_status_is_error_not(status) && !setting.path_pid.used && main->process_pid) {
+    if (F_status_is_error_not(status) && !setting.path_pid.used && !main->parameters[controller_parameter_pid].locations.used) {
 
       if (main->parameters[controller_parameter_init].result == f_console_result_found) {
         status = f_string_append(controller_path_pid_init, controller_path_pid_init_length, &setting.path_pid);
index 60b8d4f0bf5ca01b7b86f579c0913a08e60ada80..73c241c7b3c38dc10e6a9927b41ace76b8bd281f 100644 (file)
@@ -221,7 +221,6 @@ extern "C" {
 
     f_array_lengths_t remaining;
     bool process_pipe;
-    bool process_pid;
     bool as_init;
 
     f_file_t output;
@@ -246,7 +245,6 @@ extern "C" {
       controller_console_parameter_t_initialize, \
       f_array_lengths_t_initialize, \
       F_false, \
-      F_true, \
       F_false, \
       macro_f_file_t_initialize2(f_type_output, f_type_descriptor_output, f_file_flag_write_only), \
       fll_error_print_t_initialize, \
index 1084f470fcf7279a8c0bc148be0bb4f369c2b02a..be3a7aa6110a7bdf55f0d66d582ab035db1bbb5c 100644 (file)
@@ -37,7 +37,6 @@ int main(const int argc, const f_string_t *argv) {
   // when run as "init" by default, provide the default system-level init path.
   // this change must only exist within this main file so that the change only exists within the program rather than the library.
   #ifdef _controller_as_init_
-    data.process_pid = F_false;
     data.program_name = controller_name_init;
     data.program_name_long = controller_name_init_long;
     data.setting_default.string = controller_path_settings_init;
index b8c04dffc7bebc569e45ecc9a82cef3d99e60790..14211579b9e1530874dada567eb2dbb5b5b6beef 100644 (file)
@@ -401,7 +401,7 @@ extern "C" {
     f_status_t status = F_none;
 
     // only create pid file when not in validate mode.
-    if (is_entry && global.main->parameters[controller_parameter_validate].result == f_console_result_none && global.main->process_pid) {
+    if (is_entry && global.main->parameters[controller_parameter_validate].result == f_console_result_none && global.setting->path_pid.used) {
 
       status = controller_file_pid_create(global.main->pid, global.setting->path_pid);