From: Kevin Day Date: Wed, 29 Sep 2021 00:37:51 +0000 (-0500) Subject: Update: Improve pid file handling logic. X-Git-Tag: 0.5.6~33 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=41162524c57a4c59b84cf5fc8a6c6cbc297644cf;p=fll Update: Improve pid file handling logic. 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. --- diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 8740452..cde98f0 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -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); diff --git a/level_3/controller/c/controller.h b/level_3/controller/c/controller.h index 60b8d4f..73c241c 100644 --- a/level_3/controller/c/controller.h +++ b/level_3/controller/c/controller.h @@ -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, \ diff --git a/level_3/controller/c/main.c b/level_3/controller/c/main.c index 1084f47..be3a7aa 100644 --- a/level_3/controller/c/main.c +++ b/level_3/controller/c/main.c @@ -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; diff --git a/level_3/controller/c/private-controller.c b/level_3/controller/c/private-controller.c index b8c04df..1421157 100644 --- a/level_3/controller/c/private-controller.c +++ b/level_3/controller/c/private-controller.c @@ -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);