]> Kevux Git Server - controller/commitdiff
Progress: Begin migrating the project, doing some initial preparations.
authorKevin Day <kevin@kevux.org>
Thu, 4 Apr 2024 03:20:54 +0000 (22:20 -0500)
committerKevin Day <kevin@kevux.org>
Thu, 4 Apr 2024 03:20:54 +0000 (22:20 -0500)
Tweak the fakefile structure.
Remove the "as_init" fakefile mode.
Use library instead of object so that both controller and init may use the same library.
I may want to create a custon "init only" mode where init uses libinit.so rather than libcontroller.so.

Have the build settings pass "-D_controller_as_init_" directly for the init fakefile.

Add the child process exit code.
I may end up changing this again, but I wanted to start off very consistent with other projects design.

Finish the help printing process.
The program name is moved into the specific programs.

Add missing control group header file include.

Fix a mistake whee the main thread signal function is calling itself rather than the main signal handler.
This bad behavior results in a segfault.

22 files changed:
data/build/fakefile
data/build/settings
data/build/settings.controller
data/build/settings.init
sources/c/controller/controller.c
sources/c/controller/controller.h
sources/c/controller/main.c
sources/c/controller/string.c [new file with mode: 0644]
sources/c/controller/string.h [new file with mode: 0644]
sources/c/init/init.c
sources/c/init/init.h
sources/c/init/main.c
sources/c/init/string.c [new file with mode: 0644]
sources/c/init/string.h [new file with mode: 0644]
sources/c/main/common/enumeration.h
sources/c/main/common/string.c
sources/c/main/common/string.h
sources/c/main/common/type.h
sources/c/main/controller.h
sources/c/main/print/message.c
sources/c/main/print/message.h
sources/c/main/thread.c

index 1de733a2476144161a25116bc56ce5fa9c5bd5f2..2c640099992eb2252b6be956f6202ef54aeba28a 100644 (file)
@@ -12,11 +12,11 @@ main:
   build settings.controller
   build settings.init
 
-build_controller:
+main_controller:
   build settings
   build settings.controller
 
-build_init:
+main_init:
   build settings
   build settings.init
 
@@ -35,17 +35,17 @@ install_init:
 
 help:
   print
-  print context:'title'Fakefile Options for Controller Program.context:'reset'
+  print context:'title'Fakefile Options for the Controller and the Init Programs.context:'reset'
 
   print
   print The following operations are available\:
   print "  - context:'notable'help:context:'reset'               Perform the help operation, printing this message."
-  print "  - context:'notable'build_controller:context:'reset'   Compilation using the build settings mode for the controller program."
-  print "  - context:'notable'build_init:context:'reset'         Compilation using the build settings mode for the init program."
-  print "  - context:'notable'install:context:'reset'            A helper operation that simply calls the ./install.sh script with default settings."
-  print "  - context:'notable'install_controller:context:'reset' A helper operation that simply calls the ./install.sh script with default settings."
-  print "  - context:'notable'install_init:context:'reset'       A helper operation that simply calls the ./install.sh script with default settings."
-  print "  - context:'notable'main:context:'reset'               The default compilation using the build settings mode."
+  print "  - context:'notable'install:context:'reset'            A helper operation that calls the ./install.sh script for both the controller and init programs."
+  print "  - context:'notable'install_controller:context:'reset' A helper operation that calls the ./install.sh script for the controller program."
+  print "  - context:'notable'install_init:context:'reset'       A helper operation that calls the ./install.sh script for the init program."
+  print "  - context:'notable'main:context:'reset'               Compilation using the build settings mode for both the controller and init programs (default)."
+  print "  - context:'notable'main_controller:context:'reset'    Compilation using the build settings mode for the controller program."
+  print "  - context:'notable'main_init:context:'reset'          Compilation using the build settings mode for the init program."
 
   print
   print The context:'notable'install context:'reset'operation supports the context:'notable'work,context:'reset' context:'notable'verbosity,context:'reset' and context:'notable'color context:'reset'parameters.
index d074de00a772c0aa3a863d01f749283c2f2c2f64..592c2c8b4281701093a395c305ab89a82e2f291f 100644 (file)
@@ -22,7 +22,7 @@ version_micro 0
 version_file micro
 version_target minor
 
-modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless as_init
+modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless
 modes_default monolithic thread gcc
 
 build_compiler gcc
@@ -40,9 +40,9 @@ build_libraries-individual_thread -lf_thread
 build_libraries-level -lfll_2 -lfll_1 -lfll_0
 build_libraries-monolithic -lfll
 
-build_sources_object main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c
-build_sources_object main/print/data.c main/print/debug.c main/print/error.c main/print/message.c main/print/verbose.c main/print/warning.c
-build_sources_object main/signal.c main/thread.c
+build_sources_library main/common.c main/common/define.c main/common/enumeration.c main/common/print.c main/common/string.c main/common/type.c
+build_sources_library main/print/data.c main/print/debug.c main/print/error.c main/print/message.c main/print/verbose.c main/print/warning.c
+build_sources_library main/signal.c main/thread.c
 
 build_sources_headers main/common.h main/controller.h main/common/define.h main/common/enumeration.h main/common/print.h main/common/string.h main/common/type.h
 build_sources_headers main/print/data.h main/print/debug.h main/print/error.h main/print/message.h main/print/verbose.h main/print/warning.h
@@ -81,7 +81,6 @@ environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY L
 defines -D_libcap_legacy_only_
 defines-threadless -D_di_thread_support_
 defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_
-defines-as_init -D_controller_as_init_
 
 flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces
 flags -fstack-clash-protection -fno-delete-null-pointer-checks
index 6330ad06b82a9757e3997393bed01b1d03628dc5..faaae85721df7a9cbab6789ba29c152c64e5caa6 100644 (file)
@@ -22,7 +22,7 @@ version_micro 0
 version_file micro
 version_target minor
 
-modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless as_init
+modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless
 modes_default monolithic thread gcc
 
 build_compiler gcc
@@ -31,7 +31,7 @@ build_indexer ar
 build_indexer_arguments rcs
 build_language c
 
-build_libraries -lc -lcap
+build_libraries -lc -lcap -lcontroller
 build_libraries-individual -lfll_control_group -lfll_error -lfll_execute -lfll_fss -lfll_print -lfll_program -lfll_status_string
 build_libraries-individual_thread -lf_thread
 build_libraries-individual -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_path -lfl_print
@@ -40,15 +40,9 @@ build_libraries-individual_thread -lf_thread
 build_libraries-level -lfll_2 -lfll_1 -lfll_0
 build_libraries-monolithic -lfll
 
-build_objects_library main/common.o main/common/define.o main/common/enumeration.o main/common/print.o main/common/string.o main/common/type.o
-build_objects_library main/print/data.o main/print/debug.o main/print/error.o main/print/message.o main/print/verbose.o main/print/warning.o
-build_objects_library main/signal.o main/thread.o
+build_sources_program controller/config.c controller/main.c controller/controller.c controller/string.c
 
-build_sources_library controller/controller.c
-
-build_sources_program controller/config.c controller/main.c
-
-build_sources_headers controller/controller.h
+build_sources_headers controller/controller.h controller/string.h
 
 build_sources_documentation man
 
@@ -83,7 +77,6 @@ environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY L
 defines -D_libcap_legacy_only_
 defines-threadless -D_di_thread_support_
 defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_
-defines-as_init -D_controller_as_init_
 
 flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces
 flags -fstack-clash-protection -fno-delete-null-pointer-checks
index ed9ae18265d9a3e729ecceea524728141037114a..71b4b1a475ec07c1e7451c829b754d91bb670450 100644 (file)
@@ -22,7 +22,7 @@ version_micro 0
 version_file micro
 version_target minor
 
-modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless as_init
+modes individual individual_thread level monolithic clang gcc test fanalyzer coverage thread threadless
 modes_default monolithic thread gcc
 
 build_compiler gcc
@@ -31,7 +31,7 @@ build_indexer ar
 build_indexer_arguments rcs
 build_language c
 
-build_libraries -lc -lcap
+build_libraries -lc -lcap -lcontroller
 build_libraries-individual -lfll_control_group -lfll_error -lfll_execute -lfll_fss -lfll_print -lfll_program -lfll_status_string
 build_libraries-individual_thread -lf_thread
 build_libraries-individual -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_path -lfl_print
@@ -40,15 +40,9 @@ build_libraries-individual_thread -lf_thread
 build_libraries-level -lfll_2 -lfll_1 -lfll_0
 build_libraries-monolithic -lfll
 
-build_objects_library main/common.o main/common/define.o main/common/enumeration.o main/common/print.o main/common/string.o main/common/type.o
-build_objects_library main/print/data.o main/print/debug.o main/print/error.o main/print/message.o main/print/verbose.o main/print/warning.o
-build_objects_library main/signal.o main/thread.o
+build_sources_program init/config.c init/main.c init/init.c init/string.c
 
-build_sources_library init/init.c
-
-build_sources_program init/config.c init/main.c
-
-build_sources_headers init/init.h
+build_sources_headers init/init.h init/string.h
 
 build_sources_documentation man
 
@@ -80,10 +74,9 @@ environment PATH LD_LIBRARY_PATH
 environment LANG LC_ALL LC_COLLATE LC_CTYPE LC_FASTMSG LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LOCPATH NLSPATH
 
 #defines -D_di_libcap_
-defines -D_libcap_legacy_only_
+defines -D_controller_as_init_ -D_libcap_legacy_only_
 defines-threadless -D_di_thread_support_
 defines-thread -D_pthread_attr_unsupported_ -D_pthread_sigqueue_unsupported_
-defines-as_init -D_controller_as_init_
 
 flags -O2 -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses -Wno-missing-braces
 flags -fstack-clash-protection -fno-delete-null-pointer-checks
index a74c3a894ea1d0086b25985375043c5814da0bce..a22a8eeeadb68a8492b9790c84551be26341aa17 100644 (file)
@@ -25,7 +25,7 @@ extern "C" {
 
     if (main->setting.flag & controller_main_flag_version_copyright_help_e) {
       if (main->setting.flag & controller_main_flag_help_e) {
-        controller_main_print_message_help(&main->program.message);
+        controller_main_print_message_help(&main->program.message, F_false);
       }
       else if (main->setting.flag & controller_main_flag_version_e) {
         fll_program_print_version(&main->program.message, controller_program_version_s);
index 65b6fa72b40266fc3512050b50c22b3f8af590ea..db615524ff6446386450171dab910d53e29a4652 100644 (file)
@@ -61,6 +61,7 @@
 #include <program/controller/main/print/warning.h>
 #include <program/controller/main/signal.h>
 #include <program/controller/main/thread.h>
+#include <program/controller/controller/string.h>
 
 #ifdef __cplusplus
 extern "C" {
index 935616e811f434976fa41b0140933018a528d600..2d413c667e317d4d58f08b23cabc83179f9ba9e6 100644 (file)
@@ -15,8 +15,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.program.output.custom = (void *) &data;
   data.program.warning.custom = (void *) &data;
 
-  data.setting.program_name = &controller_program_name_s;
-  data.setting.program_name_long = &controller_program_name_long_s;
+  data.setting.program_name = &controller_controller_program_name_s;
+  data.setting.program_name_long = &controller_controller_program_name_long_s;
 
   f_console_parameter_t parameters[] = controller_console_parameter_t_initialize;
 
@@ -72,5 +72,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   fll_program_standard_set_down(&data.program);
 
+  if (data.setting.state.status == F_child) {
+    exit(data.program.child);
+  }
+
   return (F_status_is_error(data.setting.state.status) || data.setting.state.status == F_false) ? 1 : 0;
 }
diff --git a/sources/c/controller/string.c b/sources/c/controller/string.c
new file mode 100644 (file)
index 0000000..c7b2c2b
--- /dev/null
@@ -0,0 +1,14 @@
+#include "controller.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_controller_program_name_s_
+  const f_string_static_t controller_controller_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_controller_program_name_s, 0, CONTROLLER_controller_program_name_s_length);
+  const f_string_static_t controller_controller_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_controller_program_name_long_s, 0, CONTROLLER_controller_program_name_long_s_length);
+#endif // _di_controller_controller_program_name_s_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/sources/c/controller/string.h b/sources/c/controller/string.h
new file mode 100644 (file)
index 0000000..ab36bb1
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common string structures for the controller program.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_controller_string_h
+#define _controller_controller_string_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The program name.
+ */
+#ifndef _di_controller_controller_program_name_s_
+  #define CONTROLLER_controller_program_name_s      "controller"
+  #define CONTROLLER_controller_program_name_long_s "Controller"
+
+  #define CONTROLLER_controller_program_name_s_length      10
+  #define CONTROLLER_controller_program_name_long_s_length 10
+
+  extern const f_string_static_t controller_controller_program_name_s;
+  extern const f_string_static_t controller_controller_program_name_long_s;
+#endif // _di_controller_controller_program_name_s_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_controller_string_h
index 7a62eeeb07accfdd58ab91118948e9bf816dbe43..a040e13bcbe572416a0ed431a01126b0285541e2 100644 (file)
@@ -25,7 +25,7 @@ extern "C" {
 
     if (main->setting.flag & controller_main_flag_version_copyright_help_e) {
       if (main->setting.flag & controller_main_flag_help_e) {
-        controller_main_print_message_help(&main->program.message);
+        controller_main_print_message_help(&main->program.message, F_true);
       }
       else if (main->setting.flag & controller_main_flag_version_e) {
         fll_program_print_version(&main->program.message, controller_program_version_s);
index aa55ecac0ae37aaa0aecf06262d11711bf18e533..5e4d01d7689c4b3dbc790bd650b968bbf54b1717 100644 (file)
@@ -61,6 +61,7 @@
 #include <program/controller/main/print/warning.h>
 #include <program/controller/main/signal.h>
 #include <program/controller/main/thread.h>
+#include <program/controller/init/string.h>
 
 #ifdef __cplusplus
 extern "C" {
index 5c5003a054cbbf33461666811f24d0f55612a211..fc670d3e74d6801e4f94178749b6d6f81c68572a 100644 (file)
@@ -15,8 +15,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.program.output.custom = (void *) &data;
   data.program.warning.custom = (void *) &data;
 
-  data.setting.program_name = &controller_program_name_s;
-  data.setting.program_name_long = &controller_program_name_long_s;
+  data.setting.program_name = &controller_init_program_name_s;
+  data.setting.program_name_long = &controller_init_program_name_long_s;
 
   f_console_parameter_t parameters[] = controller_console_parameter_t_initialize;
 
@@ -72,5 +72,9 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   fll_program_standard_set_down(&data.program);
 
+  if (data.setting.state.status == F_child) {
+    exit(data.program.child);
+  }
+
   return (F_status_is_error(data.setting.state.status) || data.setting.state.status == F_false) ? 1 : 0;
 }
diff --git a/sources/c/init/string.c b/sources/c/init/string.c
new file mode 100644 (file)
index 0000000..ff1fd9e
--- /dev/null
@@ -0,0 +1,14 @@
+#include "init.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_controller_init_program_name_s_
+  const f_string_static_t controller_init_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_init_program_name_s, 0, CONTROLLER_init_program_name_s_length);
+  const f_string_static_t controller_init_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_init_program_name_long_s, 0, CONTROLLER_init_program_name_long_s_length);
+#endif // _di_controller_init_program_name_s_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/sources/c/init/string.h b/sources/c/init/string.h
new file mode 100644 (file)
index 0000000..5f8e82d
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: Controller
+ * API Version: 0.7
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Provides the common string structures for the init program.
+ *
+ * This is auto-included and should not need to be explicitly included.
+ */
+#ifndef _controller_init_string_h
+#define _controller_init_string_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The program name.
+ */
+#ifndef _di_controller_init_program_name_s_
+  #define CONTROLLER_init_program_name_s      "init"
+  #define CONTROLLER_init_program_name_long_s "Init"
+
+  #define CONTROLLER_init_program_name_s_length      4
+  #define CONTROLLER_init_program_name_long_s_length 4
+
+  extern const f_string_static_t controller_init_program_name_s;
+  extern const f_string_static_t controller_init_program_name_long_s;
+#endif // _di_controller_init_program_name_s_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _controller_init_string_h
index 19b272b2dbbf41689959e945eab4cc190a7b0250..fedbd4db35330983f17c63cb821fcd151b874073 100644 (file)
@@ -62,10 +62,19 @@ extern "C" {
     { \
       macro_fll_program_console_parameter_standard_initialize, \
       \
-      macro_f_console_parameter_t_initialize_3(controller_short_controller_s, controller_long_controller_s, 0, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_cgroup_s,          controller_long_cgroup_s,          1, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_daemon_s,          controller_long_daemon_s,          0, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_init_s,            controller_long_init_s,            0, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_interruptible_s,   controller_long_interruptible_s,   0, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_pid_s,             controller_long_pid_s,             1, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_settings_s,        controller_long_settings_s,        1, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_simulate_s,        controller_long_simulate_s,        0, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_socket_s,          controller_long_socket_s,          1, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_uninterruptible_s, controller_long_uninterruptible_s, 0, f_console_flag_normal_e), \
+      macro_f_console_parameter_t_initialize_3(controller_short_validate_s,        controller_long_validate_s,        0, f_console_flag_normal_e), \
     }
 
-  #define controller_parameter_total_d (f_console_parameter_state_type_total_d + 1)
+  #define controller_parameter_total_d (f_console_parameter_state_type_total_d + 10)
 #endif // _di_controller_parameter_e_
 
 /**
index f69607d0a7d89db7a6f08912d9d7472a3f7098ac..86306639471b62e16f3d91a4befb1b0164ac867d 100644 (file)
@@ -8,15 +8,28 @@ extern "C" {
   const f_string_static_t controller_program_version_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_version_s, 0, CONTROLLER_program_version_s_length);
 #endif // _di_controller_program_version_s_
 
-#ifndef _di_controller_program_name_s_
-  const f_string_static_t controller_program_name_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_name_s, 0, CONTROLLER_program_name_s_length);
-  const f_string_static_t controller_program_name_long_s = macro_f_string_static_t_initialize_1(CONTROLLER_program_name_long_s, 0, CONTROLLER_program_name_long_s_length);
-#endif // _di_controller_program_name_s_
-
 #ifndef _di_controller_parameter_s_
-  const f_string_static_t controller_short_controller_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_controller_s, 0, CONTROLLER_short_controller_s_length);
+  const f_string_static_t controller_short_cgroup_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_cgroup_s, 0, CONTROLLER_short_cgroup_s_length);
+  const f_string_static_t controller_short_daemon_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_daemon_s, 0, CONTROLLER_short_daemon_s_length);
+  const f_string_static_t controller_short_init_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_init_s, 0, CONTROLLER_short_init_s_length);
+  const f_string_static_t controller_short_interruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_interruptible_s, 0, CONTROLLER_short_interruptible_s_length);
+  const f_string_static_t controller_short_pid_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_pid_s, 0, CONTROLLER_short_pid_s_length);
+  const f_string_static_t controller_short_settings_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_settings_s, 0, CONTROLLER_short_settings_s_length);
+  const f_string_static_t controller_short_simulate_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_simulate_s, 0, CONTROLLER_short_simulate_s_length);
+  const f_string_static_t controller_short_socket_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_socket_s, 0, CONTROLLER_short_socket_s_length);
+  const f_string_static_t controller_short_uninterruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_uninterruptible_s, 0, CONTROLLER_short_uninterruptible_s_length);
+  const f_string_static_t controller_short_validate_s = macro_f_string_static_t_initialize_1(CONTROLLER_short_validate_s, 0, CONTROLLER_short_validate_s_length);
 
-  const f_string_static_t controller_long_controller_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_controller_s, 0, CONTROLLER_long_controller_s_length);
+  const f_string_static_t controller_long_cgroup_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_cgroup_s, 0, CONTROLLER_long_cgroup_s_length);
+  const f_string_static_t controller_long_daemon_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_daemon_s, 0, CONTROLLER_long_daemon_s_length);
+  const f_string_static_t controller_long_init_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_init_s, 0, CONTROLLER_long_init_s_length);
+  const f_string_static_t controller_long_interruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_interruptible_s, 0, CONTROLLER_long_interruptible_s_length);
+  const f_string_static_t controller_long_pid_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_pid_s, 0, CONTROLLER_long_pid_s_length);
+  const f_string_static_t controller_long_settings_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_settings_s, 0, CONTROLLER_long_settings_s_length);
+  const f_string_static_t controller_long_simulate_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_simulate_s, 0, CONTROLLER_long_simulate_s_length);
+  const f_string_static_t controller_long_socket_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_socket_s, 0, CONTROLLER_long_socket_s_length);
+  const f_string_static_t controller_long_uninterruptible_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_uninterruptible_s, 0, CONTROLLER_long_uninterruptible_s_length);
+  const f_string_static_t controller_long_validate_s = macro_f_string_static_t_initialize_1(CONTROLLER_long_validate_s, 0, CONTROLLER_long_validate_s_length);
 #endif // _di_controller_parameter_s_
 
 #ifdef __cplusplus
index fff2a1eccfa0a4954cd4ff2c36515dbf5db2588f..5d2ea633a7f3d998b90bb904191f36e062ee1d78 100644 (file)
@@ -46,34 +46,74 @@ extern "C" {
 #endif // _di_controller_program_version_s_
 
 /**
- * The program name.
- */
-#ifndef _di_controller_program_name_s_
-  #define CONTROLLER_program_name_s      "controller"
-  #define CONTROLLER_program_name_long_s "Controller"
-
-  #define CONTROLLER_program_name_s_length      10
-  #define CONTROLLER_program_name_long_s_length 10
-
-  extern const f_string_static_t controller_program_name_s;
-  extern const f_string_static_t controller_program_name_long_s;
-#endif // _di_controller_program_name_s_
-
-/**
  * The main program parameters.
  */
 #ifndef _di_controller_parameter_s_
-  #define CONTROLLER_short_controller_s "e"
-
-  #define CONTROLLER_long_controller_s "controller"
-
-  #define CONTROLLER_short_controller_s_length 1
-
-  #define CONTROLLER_long_controller_s_length 7
-
-  extern const f_string_static_t controller_short_controller_s;
-
-  extern const f_string_static_t controller_long_controller_s;
+  #define CONTROLLER_short_cgroup_s          "c"
+  #define CONTROLLER_short_daemon_s          "d"
+  #define CONTROLLER_short_init_s            "I"
+  #define CONTROLLER_short_interruptible_s   "i"
+  #define CONTROLLER_short_pid_s             "p"
+  #define CONTROLLER_short_settings_s        "s"
+  #define CONTROLLER_short_simulate_s        "S"
+  #define CONTROLLER_short_socket_s          "k"
+  #define CONTROLLER_short_uninterruptible_s "U"
+  #define CONTROLLER_short_validate_s        "v"
+
+  #define CONTROLLER_long_cgroup_s          "cgroup"
+  #define CONTROLLER_long_daemon_s          "daemon"
+  #define CONTROLLER_long_init_s            "init"
+  #define CONTROLLER_long_interruptible_s   "interruptible"
+  #define CONTROLLER_long_pid_s             "pid"
+  #define CONTROLLER_long_settings_s        "settings"
+  #define CONTROLLER_long_simulate_s        "simulate"
+  #define CONTROLLER_long_socket_s          "socket"
+  #define CONTROLLER_long_uninterruptible_s "uninterruptible"
+  #define CONTROLLER_long_validate_s        "validate"
+
+  #define CONTROLLER_short_cgroup_s_length          1
+  #define CONTROLLER_short_daemon_s_length          1
+  #define CONTROLLER_short_init_s_length            1
+  #define CONTROLLER_short_interruptible_s_length   1
+  #define CONTROLLER_short_pid_s_length             1
+  #define CONTROLLER_short_settings_s_length        1
+  #define CONTROLLER_short_simulate_s_length        1
+  #define CONTROLLER_short_socket_s_length          1
+  #define CONTROLLER_short_uninterruptible_s_length 1
+  #define CONTROLLER_short_validate_s_length        1
+
+  #define CONTROLLER_long_cgroup_s_length          6
+  #define CONTROLLER_long_daemon_s_length          6
+  #define CONTROLLER_long_init_s_length            4
+  #define CONTROLLER_long_interruptible_s_length   13
+  #define CONTROLLER_long_pid_s_length             3
+  #define CONTROLLER_long_settings_s_length        8
+  #define CONTROLLER_long_simulate_s_length        8
+  #define CONTROLLER_long_socket_s_length          6
+  #define CONTROLLER_long_uninterruptible_s_length 15
+  #define CONTROLLER_long_validate_s_length        8
+
+  extern const f_string_static_t controller_short_cgroup_s;
+  extern const f_string_static_t controller_short_daemon_s;
+  extern const f_string_static_t controller_short_init_s;
+  extern const f_string_static_t controller_short_interruptible_s;
+  extern const f_string_static_t controller_short_pid_s;
+  extern const f_string_static_t controller_short_settings_s;
+  extern const f_string_static_t controller_short_simulate_s;
+  extern const f_string_static_t controller_short_socket_s;
+  extern const f_string_static_t controller_short_uninterruptible_s;
+  extern const f_string_static_t controller_short_validate_s;
+
+  extern const f_string_static_t controller_long_cgroup_s;
+  extern const f_string_static_t controller_long_daemon_s;
+  extern const f_string_static_t controller_long_init_s;
+  extern const f_string_static_t controller_long_interruptible_s;
+  extern const f_string_static_t controller_long_pid_s;
+  extern const f_string_static_t controller_long_settings_s;
+  extern const f_string_static_t controller_long_simulate_s;
+  extern const f_string_static_t controller_long_socket_s;
+  extern const f_string_static_t controller_long_uninterruptible_s;
+  extern const f_string_static_t controller_long_validate_s;
 #endif // _di_controller_parameter_s_
 
 #ifdef __cplusplus
index 4a9bd238b4dfbe6cba18a87003ae5ed4cda9125a..5f59d747601bdb1febff4b4b0707e2f925952c24 100644 (file)
@@ -42,6 +42,9 @@ extern "C" {
  *
  * status_signal: A status used eclusively by the threaded signal handler.
  * state:         The state data used when processing the FSS data.
+ *
+ * program_name:      The short program name.
+ * program_name_long: The long program name.
  */
 #ifndef _di_controller_setting_t_
   typedef struct {
index 16e3257bb9da8be63dd6e886c1b3c14fcfd82823..5edeb9c004233e1ec2bdc57fd7834ebb73d13cfc 100644 (file)
@@ -26,6 +26,7 @@
 #include <fll/level_0/utf.h>
 #include <fll/level_0/color.h>
 #include <fll/level_0/compare.h>
+#include <fll/level_0/control_group.h>
 #include <fll/level_0/console.h>
 #include <fll/level_0/conversion.h>
 #include <fll/level_0/pipe.h>
index 1a2a127766877b04da4b53007012b9ce7a68e242..42f1e771b74defdbf2b4eb7acf9e4859b6255246 100644 (file)
@@ -5,23 +5,41 @@ extern "C" {
 #endif
 
 #ifndef _di_controller_main_print_message_help_
-  f_status_t controller_main_print_message_help(fl_print_t * const print) {
+  f_status_t controller_main_print_message_help(fl_print_t * const print, const uint8_t uninterrupt) {
 
-    if (!print) return F_status_set_error(F_output_not);
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
+
+    controller_main_t * const main = (controller_main_t *) print->custom;
 
     f_file_stream_lock(print->to);
 
-    fll_program_print_help_header(print, controller_program_name_long_s, controller_program_version_s);
+    fll_program_print_help_header(print, *main->setting.program_name_long, controller_program_version_s);
 
     fll_program_print_help_option_standard(print);
 
     f_print_dynamic_raw(f_string_eol_s, print->to);
 
-    fll_program_print_help_option(print, controller_short_controller_s, controller_long_controller_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "This is an controller program parameter.");
+    fll_program_print_help_option(print, controller_short_cgroup_s, controller_long_cgroup_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "         Specify a custom control group file path, such as '" F_control_group_path_system_prefix_s F_control_group_path_system_default_s "'.");
+    fll_program_print_help_option(print, controller_short_daemon_s, controller_long_daemon_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "         Run in daemon only mode (do not process the entry).");
+    fll_program_print_help_option(print, controller_short_init_s, controller_long_init_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "           The program will run as an init replacement.");
+    fll_program_print_help_option(print, controller_short_interruptible_s, controller_long_interruptible_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "  Designate that this program can be interrupted by a signal.");
+    fll_program_print_help_option(print, controller_short_pid_s, controller_long_pid_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "            Specify a custom pid file path, such as 'controller/run/default.pid'.");
+    fll_program_print_help_option(print, controller_short_settings_s, controller_long_settings_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "       Specify a custom settings path, such as 'controller/'.");
+    fll_program_print_help_option(print, controller_short_simulate_s, controller_long_simulate_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "       Run as a simulation.");
+    fll_program_print_help_option(print, controller_short_socket_s, controller_long_socket_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "         Specify a custom socket file path, such as 'controller/run/default.socket'.");
+    fll_program_print_help_option(print, controller_short_uninterruptible_s, controller_long_uninterruptible_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "Designate that this program cannot be interrupted by a signal.");
+    fll_program_print_help_option(print, controller_short_validate_s, controller_long_validate_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "       Validate the settings (entry and rules) without running (does not simulate).");
 
     f_print_dynamic_raw(f_string_eol_s, print->to);
 
-    fll_program_print_help_usage(print, controller_program_name_s, f_string_empty_s);
+    fll_program_print_help_usage(print, *main->setting.program_name, f_string_empty_s);
+
+    fl_print_format("%r  When both the %[%r%r%] parameter and the", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, controller_long_simulate_s, print->set->notable);
+    fl_print_format(" %[%r%r%] parameter are specified, then additional information on each would be executed rule is printed but no simulation is performed.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, controller_long_validate_s, print->set->notable, f_string_eol_s, f_string_eol_s);
+
+    fl_print_format("  The default interrupt behavior is to operate as if the %[%r%r%] parameter is passed.%r%r", print->to, print->set->notable, f_console_symbol_long_normal_s, uninterrupt ? controller_long_uninterruptible_s : controller_long_interruptible_s, print->set->notable, f_string_eol_s, f_string_eol_s);
+
+    fl_print_format("  Specify an empty string for the %[%r%r%] parameter to disable pid file creation for this program.%r", print->to, print->set->notable, f_console_symbol_long_normal_s, controller_long_pid_s, print->set->notable, f_string_eol_s);
 
     f_file_stream_flush(print->to);
     f_file_stream_unlock(print->to);
index 3be5523b489834bdbbabf50c8173a5f1450f2b38..c215bb0cf124eae16eb5b0fe754bf2089752b53f 100644 (file)
@@ -25,6 +25,9 @@ extern "C" {
  *   This requires print.custom to be controller_main_t.
  *
  *   This does not alter print.custom.setting.state.status.
+ * @param uninterrupt
+ *   Set to F_true to print that the default behavior is uninterruptible.
+ *   Otherwise, print that the default behavior is interruptible.
  *
  * @return
  *   F_okay on success.
@@ -41,7 +44,7 @@ extern "C" {
  * @see fll_program_print_help_usage()
  */
 #ifndef _di_controller_main_print_message_help_
-  extern f_status_t controller_main_print_message_help(fl_print_t * const print);
+  extern f_status_t controller_main_print_message_help(fl_print_t * const print, const uint8_t uninterrupt);
 #endif // _di_controller_main_print_message_help_
 
 #ifdef __cplusplus
index 12af9a7f709dee91db33daf5958343017451bc0b..2214fb7724cde75116fb435516d66c182539a703 100644 (file)
@@ -10,7 +10,7 @@ extern "C" {
     f_thread_cancel_state_set(PTHREAD_CANCEL_DEFERRED, 0);
 
     if (main) {
-      controller_main_thread_signal((controller_main_t *) main);
+      controller_main_signal_handler((controller_main_t *) main);
     }
 
     return 0;