The `fll_program_standard_signal_received_wait()` is now added because a lot of this code is repeated forr every single FLL program.
The `fll_program_standard_signal_received()` is refactored to return a status code to match the newly added `ll_program_standard_signal_received_wait()`.
The `status_signal` can now be moved into the main program settings structure.
The `status_signal` is renamed to `signal_status` to keep the naming more consistent.
This also exposes and fixes a race condition in how the pre-existing threaded signal handling is being used.
The check for `program.signal.id` that then opens a signal via `f_signal_open()` in the thread is not necessary because the signal id from the parent thread is preserved.
The `f_signal_close()` in the thread ends up prematurely closing the signal because the parent thread signal id is passed to the child thread.
The `main->program.signal.id == -1` checks in the signal check functions end up preventing the interrupt cancel from being triggered because of the `f_signal_close()` being called in a separate thread that shares the same signal id.
//#define _di_fll_program_standard_set_up_
//#define _di_fll_program_standard_signal_handle_
//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
#define _di_private_inline_f_print_to_error_
#define _di_private_inline_private_f_print_to_error_
//#define _di_fll_program_standard_set_up_
//#define _di_fll_program_standard_signal_handle_
//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
#define _di_private_inline_f_print_to_error_
#define _di_private_inline_private_f_print_to_error_
//#define _di_fll_program_standard_set_up_
//#define _di_fll_program_standard_signal_handle_
//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
#define _di_private_inline_f_print_to_error_
#define _di_private_inline_private_f_print_to_error_
//#define _di_fll_program_standard_set_up_
//#define _di_fll_program_standard_signal_handle_
//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
#define _di_private_inline_f_print_to_error_
#define _di_private_inline_private_f_print_to_error_
//#define _di_fll_program_standard_set_up_
//#define _di_fll_program_standard_signal_handle_
//#define _di_fll_program_standard_signal_received_
+//#define _di_fll_program_standard_signal_received_wait_
#define _di_private_inline_f_print_to_error_
#define _di_private_inline_private_f_print_to_error_
#endif // !defined(_di_fll_program_print_help_option_) || !defined(_di_fll_program_print_help_option_standard_)
#if !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_handle_)
- uint32_t private_fll_program_standard_signal_received(fll_program_data_t * const program) {
+ f_status_t private_fll_program_standard_signal_received(fll_program_data_t * const program) {
- if (!program || program->signal.id == -1) return 0;
+ if (!program || program->signal.id == -1) return F_status_set_error(F_parameter);
struct signalfd_siginfo information;
memset(&information, 0, sizeof(struct signalfd_siginfo));
- if (f_signal_read(program->signal, 0, &information) == F_signal) {
+ program->signal_status = f_signal_read(program->signal, 0, &information);
+ if (F_status_is_error(program->signal_status)) return program->signal_status;
+
+ if (program->signal_status == F_signal) {
switch (information.ssi_signo) {
case F_signal_abort:
case F_signal_broken_pipe:
case F_signal_termination:
program->signal_received = information.ssi_signo;
- return information.ssi_signo;
+ return F_interrupt;
}
}
- return 0;
+ return F_interrupt_not;
}
#endif // !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_handle_)
* @param program
* The program data.
*
+ * This alters program:
+ * - signal_received: Stores the signal received if deemed appropraite.
+ * - signal_status: Stores the status of the signal checking function.
+ *
* @return
- * A positive number representing a valid signal on signal received.
- * 0 on no signal received or when main is NULL.
+ * F_interrupt on success with interrupt received.
+ * F_interrupt_not on success without interrupt received.
+ *
+ * Errors (with error bit) from: f_signal_read().
*
* @see f_signal_read()
*
* @see fll_program_standard_signal_handle()
*/
#if !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_handle_)
- uint32_t private_fll_program_standard_signal_received(fll_program_data_t * const program) F_attribute_visibility_internal_d;
+ f_status_t private_fll_program_standard_signal_received(fll_program_data_t * const program) F_attribute_visibility_internal_d;
#endif // !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_handle_)
/**
#endif // _di_fll_program_standard_set_up_
#ifndef _di_fll_program_standard_signal_received_
- uint32_t fll_program_standard_signal_received(fll_program_data_t * const program) {
+ f_status_t fll_program_standard_signal_received(fll_program_data_t * const program) {
#ifndef _di_level_2_parameter_checking_
- if (!program) return 0;
+ if (!program || program->signal.id == -1) return F_status_set_error(F_parameter);
#endif // _di_level_2_parameter_checking_
return private_fll_program_standard_signal_received(program);
}
#endif // _di_fll_program_standard_signal_received_
+#ifndef _di_fll_program_standard_signal_received_wait_
+ f_status_t fll_program_standard_signal_received_wait(fll_program_data_t * const program, const f_number_unsigned_t max) {
+ #ifndef _di_level_2_parameter_checking_
+ if (!program || program->signal.id == -1) return F_status_set_error(F_parameter);
+ #endif // _di_level_2_parameter_checking_
+
+ // This utilizes a local status to better control the status within this scope as this function is expected to be run in a threaded environment.
+ siginfo_t information;
+ f_number_unsigned_t failsafe = 0;
+ f_status_t status = F_okay;
+
+ memset(&information, 0, sizeof(siginfo_t));
+
+ program->signal_received = 0;
+
+ do {
+ memset(&information, 0, sizeof(siginfo_t));
+
+ program->signal_status = status = f_signal_wait(&program->signal.set, &information);
+
+ if (F_status_is_error(status) && F_status_set_fine(status) != F_interrupt) {
+ if (++failsafe >= max) {
+ status = F_status_set_error(F_maximum);
+
+ break;
+ }
+ }
+
+ switch (information.si_signo) {
+ case F_signal_abort:
+ case F_signal_broken_pipe:
+ case F_signal_hangup:
+ case F_signal_interrupt:
+ case F_signal_quit:
+ case F_signal_termination:
+ program->signal_received = information.si_signo;
+ program->signal_status = status = F_interrupt;
+
+ break;
+
+ default:
+ failsafe = 0;
+ program->signal_status = F_okay;
+
+ break;
+ }
+
+ } while (F_status_set_fine(status) != F_interrupt);
+
+ return status;
+ }
+#endif // _di_fll_program_standard_signal_received_wait_
+
#ifndef _di_fll_program_standard_signal_handle_
void fll_program_standard_signal_handle(f_state_t * const state, void * const internal) {
#ifndef _di_level_2_parameter_checking_
fll_program_data_t * const program = (fll_program_data_t *) state->custom;
- program->signal_received = private_fll_program_standard_signal_received(program);
+ const f_status_t status = program->signal.id == -1
+ ? F_interrupt_not
+ : private_fll_program_standard_signal_received(program);
- if (program->signal_received == F_signal_abort || program->signal_received == F_signal_broken_pipe || program->signal_received == F_signal_hangup || program->signal_received == F_signal_interrupt || program->signal_received == F_signal_quit || program->signal_received == F_signal_termination) {
- state->status = F_status_set_error(F_interrupt);
- }
- else {
- state->status = F_interrupt_not;
- }
+ state->status = F_status_set_fine(status) == F_interrupt ? F_status_set_error(F_interrupt) : status;
}
#endif // _di_fll_program_standard_signal_handle_
/**
* Check to see if a process signal is received.
*
- * Only signals that are blocked via main.signal will be received.
+ * Only signals that are blocked via program.signal will be received.
*
- * If no signals are blocked, then this always returns F_false.
+ * If no signals are blocked, then this always returns F_interrupt_not.
+ *
+ * This only reacts on the following signals:
+ * - F_signal_abort
+ * - F_signal_broken_pipe
+ * - F_signal_hangup
+ * - F_signal_interrupt
+ * - F_signal_quit
+ * - F_signal_termination
*
* @param program
* The program data.
- * The program.signal must be used to designate blocked signals.
+ *
+ * This alters program:
+ * - signal_received: Stores the signal received if deemed appropraite.
+ * - signal_status: Stores the status of the signal checking function.
*
* @return
- * A positive number representing a valid signal on signal received.
- * 0 on no signal received or when main is NULL.
+ * F_interrupt on success with interrupt received.
+ * F_interrupt_not on success without interrupt received.
+ *
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_signal_read().
*
* @see f_signal_read()
*/
#ifndef _di_fll_program_standard_signal_received_
- extern uint32_t fll_program_standard_signal_received(fll_program_data_t * const program);
+ extern f_status_t fll_program_standard_signal_received(fll_program_data_t * const program);
#endif // _di_fll_program_standard_signal_received_
/**
+ * Check to see if a process signal is received, in a blocking manner.
+ *
+ * This will attempt to wait infinitely until a signal is received or enough sequential errors are greater than the given max.
+ *
+ * Only signals that are blocked via program.signal will be received.
+ *
+ * This only reacts on the following signals:
+ * - F_signal_abort
+ * - F_signal_broken_pipe
+ * - F_signal_hangup
+ * - F_signal_interrupt
+ * - F_signal_quit
+ * - F_signal_termination
+ *
+ * @param program
+ * The program data.
+ *
+ * This alters program:
+ * - signal.id: At start and on return.
+ * - signal_received: Stores the signal received if deemed appropraite.
+ * - signal_status: Stores the status of the signal checking function.
+ *
+ * @return
+ * F_interrupt on success with interrupt received.
+ * F_interrupt_not on success without interrupt received.
+ *
+ * F_maximum (with error bit) if max is reached on too many sequential errors.
+ * F_parameter (with error bit) if a parameter is invalid.
+ *
+ * Errors (with error bit) from: f_signal_wait().
+ *
+ * @see f_signal_wait()
+ */
+#ifndef _di_fll_program_standard_signal_received_wait_
+ extern f_status_t fll_program_standard_signal_received_wait(fll_program_data_t * const program, const f_number_unsigned_t max);
+#endif // _di_fll_program_standard_signal_received_wait_
+
+/**
* Standardized callback for checking for interrupts via the f_state_t interrupt callback.
*
* This only checks for the signals:
* - signal_check: A counter used to map to for reducing the amount of actual signal check calls.
* - signal_received: The signal received (if 0, then no signal is received).
* - signal: The process signal management structure.
+ * - signal_status: The status of the signal handler.
*
* - message: The output file for normal output messages (often stdout).
* - output: The output file for normal/non-message output, aka data output (often stdout or a file).
uint32_t signal_received;
uint16_t signal_check;
f_signal_t signal;
+ f_status_t signal_status;
fl_print_t message;
fl_print_t output;
0, \
0, \
f_signal_t_initialize, \
+ F_okay, \
fl_print_t_initialize, \
fl_print_t_initialize, \
macro_fl_print_t_initialize_error_1(), \
signal_received, \
signal_check, \
signal, \
+ F_okay, \
message, \
output, \
error, \
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - flag: Flags passed to the main function.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state data used when processing data.
+ * - flag: Flags passed to the main function.
+ * - state: The state data used when processing data.
*
* - first: The first position.
* - last: The last position.
#ifndef _di_byte_dump_setting_t_
typedef struct {
uint16_t flag;
-
- f_status_t status_signal;
f_state_t state;
uint64_t first;
#define byte_dump_setting_t_initialize \
{ \
byte_dump_main_flag_none_d, \
- F_okay, \
f_state_t_initialize, \
0, \
0, \
#if !defined(_di_byte_dump_signal_check_) && defined(_di_thread_support_)
f_status_t byte_dump_signal_check(byte_dump_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % byte_dump_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
#if !defined(_di_byte_dump_signal_check_) && !defined(_di_thread_support_)
f_status_t byte_dump_signal_check(byte_dump_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
if (main->program.signal_received) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= byte_dump_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, byte_dump_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_byte_dump_signal_handler_) && !defined(_di_thread_support_)
extern void byte_dump_signal_handler(byte_dump_main_t * const main);
* This is passed to the program-specific main entry point to designate program settings.
* These program settings are often processed from the program arguments (often called the command line arguments).
*
- * flag: Flags passed to the main function.
+ * Properties:
+ * - flag: Flags passed to the main function.
+ * - state: The state data used when processing the FSS data.
*
- * 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_example_setting_t_
typedef struct {
uint16_t flag;
-
- f_status_t status_signal;
f_state_t state;
const f_string_static_t *program_name;
#define example_setting_t_initialize \
{ \
example_main_flag_none_d, \
- F_okay, \
f_state_t_initialize, \
0, \
0, \
#if !defined(_di_example_signal_check_) && defined(_di_thread_support_)
f_status_t example_signal_check(example_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % example_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= example_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, example_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_example_signal_handler_) && !defined(_di_thread_support_)
extern void example_signal_handler(example_main_t * const main);
*
* @see f_directory_create()
* @see f_directory_exists()
- * @see fll_program_standard_signal_received()
*
* @see fake_build_touch()
*/
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - flag: Flags passed to the main function.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state data used when processing the FSS data.
+ * - flag: Flags passed to the main function.
+ * - state: The state data used when processing the FSS data.
*
* - build: The build directory.
* - data: The data directory.
#ifndef _di_fake_setting_t_
typedef struct {
uint32_t flag;
-
- f_status_t status_signal;
f_state_t state;
f_string_dynamic_t build;
#define fake_setting_t_initialize \
{ \
0, \
- F_okay, \
f_state_t_initialize, \
f_string_dynamic_t_initialize, \
f_string_dynamic_t_initialize, \
* Errors (with error bit) from: fake_validate_parameter_paths()
*
* @see f_string_dynamic_append()
- * @see fll_program_standard_signal_received()
* @see fake_build_operate()
* @see fake_clean_operate()
* @see fake_make_operate()
* A value of 1 is returned if status has the error bit set.
*
* @see fll_execute_program()
- * @see fll_program_standard_signal_received()
*/
#ifndef _di_fake_execute_
extern int fake_execute(fake_data_t * const data, const f_string_maps_t environment, const f_string_static_t program);
* @see f_file_stream_open()
* @see f_file_stream_read()
* @see f_memory_array_increase_by()
- * @see fll_program_standard_signal_received()
*/
#ifndef _di_fake_file_buffer_
extern void fake_file_buffer(fake_data_t * const data, const f_string_static_t path_file, const bool required, f_string_dynamic_t * const buffer);
*
* @see f_file_stream_read_block()
* @see f_memory_array_increase_by()
- * @see fll_program_standard_signal_received()
*/
#ifndef _di_fake_pipe_buffer_
extern void fake_pipe_buffer(fake_data_t * const data, f_string_dynamic_t * const buffer);
*
* @see f_file_exists()
* @see f_file_stat()
- * @see fll_program_standard_signal_received()
*/
#ifndef _di_fake_validate_parameter_paths_
extern void fake_validate_parameter_paths(fake_data_t * const data);
* @see f_string_dynamic_partial_append()
* @see fll_fss_basic_list_read()
* @see fll_fss_extended_read()
- * @see fll_program_standard_signal_received()
*
* @see fake_build_load_setting()
* @see fake_make_load_fakefile_setting_build()
fake_main_t * const main = data_make->main;
- if (fll_program_standard_signal_received(&main->program)) {
- fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
-
- main->setting.state.status = F_status_set_error(F_interrupt);
-
- return;
- }
+ if (fake_signal_check(main)) return;
// Reset the environment.
for (f_number_unsigned_t i = 0; i < data_make->environment.used; ++i) {
main->setting.state.status = fll_execute_program(program, arguments, ¶meter, 0, (void *) &return_code);
- if (fll_program_standard_signal_received(&main->program)) {
- fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
-
- main->setting.state.status = F_status_set_error(F_interrupt);
-
- return;
- }
+ if (fake_signal_check(main)) return;
if (F_status_is_error(main->setting.state.status)) {
if (F_status_set_fine(main->setting.state.status) == F_interrupt) return;
* @see f_environment_get_all()
* @see fl_environment_load_names()
* @see fll_execute_program()
- * @see fll_program_standard_signal_received()
*
* @see fake_make_operate_process_return()
*/
#if !defined(_di_fake_signal_check_) && defined(_di_thread_support_)
f_status_t fake_signal_check(fake_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % fake_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= fake_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, fake_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_fake_signal_handler_) && !defined(_di_thread_support_)
extern void fake_signal_handler(fake_main_t * const main);
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - flag: Flags passed to the main function.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state information.
+ * - flag: Flags passed to the main function.
+ * - state: The state information.
*
* - chains: An array of all chains. @todo probably should be moved into data.
* - devices: An array of all devices. @todo probably should be moved into data.
#ifndef _di_firewall_setting_t_
typedef struct {
uint16_t flag;
-
- f_status_t status_signal;
f_state_t state;
f_string_dynamics_t chains;
#define firewall_setting_t_initialize \
{ \
firewall_main_flag_none_d, \
- F_okay, \
f_state_t_initialize, \
f_string_dynamics_t_initialize, \
f_string_dynamics_t_initialize, \
#if !defined(_di_firewall_signal_check_) && defined(_di_thread_support_)
f_status_t firewall_signal_check(firewall_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % firewall_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= firewall_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, firewall_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_firewall_signal_handler_) && !defined(_di_thread_support_)
extern void firewall_signal_handler(firewall_main_t * const main);
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - flag: Flags passed to the main function.
+ * - flag: Flags passed to the main function.
+ * - state: The state information.
*
* - current: The current position within the ids, used to determine when the line is matched.
* - line: The line number to select.
* - total: The total ids across all files.
*
* - range: A range used for processing as needed.
- * -
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state information.
*
* - buffer: A buffer used for processing files.
* - ids: A cache for FLL IDs.
#ifndef _di_fss_identify_setting_t_
typedef struct {
uint16_t flag;
+ f_state_t state;
f_number_unsigned_t current;
f_number_unsigned_t line;
f_range_t range;
- f_status_t status_signal;
- f_state_t state;
-
f_file_t file;
f_string_dynamic_t buffer;
#define fss_identify_setting_t_initialize \
{ \
fss_identify_main_flag_none_d, \
+ f_state_t_initialize, \
0, \
0, \
0, \
f_range_t_initialize, \
- F_okay, \
- f_state_t_initialize, \
f_file_t_initialize, \
f_string_dynamic_t_initialize, \
f_fll_ids_t_initialize, \
#if !defined(_di_fss_identify_signal_check_) && defined(_di_thread_support_)
f_status_t fss_identify_signal_check(fss_identify_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % fss_identify_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= fss_identify_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, fss_identify_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_fss_identify_signal_handler_) && !defined(_di_thread_support_)
extern void fss_identify_signal_handler(fss_identify_main_t * const main);
* feature: Flags not passed to the main function but instead assigned by individual standards to designate how they work.
* flag: Flags passed to the main function.
* delimit_mode: The delimit mode.
- *
- * status_signal: A status used eclusively by the threaded signal handler.
- * state: The state data used when processing the FSS data.
+ * state: The state data used when processing the FSS data.
*
* delimit_depth: The delimit depth.
* select: The Content to select (column number).
uint16_t feature;
uint32_t flag;
uint8_t delimit_mode;
-
- f_status_t status_signal;
f_state_t state;
f_number_unsigned_t delimit_depth;
fss_read_main_flag_none_d, \
fss_read_feature_flag_none_d, \
fss_read_delimit_mode_all_e, \
- F_okay, \
macro_f_state_t_initialize_1(fss_read_allocation_large_d, fss_read_allocation_small_d, F_okay, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0, 0), \
0, \
0, \
#if !defined(_di_fss_read_signal_check_) && defined(_di_thread_support_)
f_status_t fss_read_signal_check(fss_read_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % fss_read_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= fss_read_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, fss_read_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_fss_read_signal_handler_) && !defined(_di_thread_support_)
extern void fss_read_signal_handler(fss_read_main_t * const main);
*
* For all function pointers on this structure, the main variable must be of type fss_write_main_t.
*
- * flag: Flags passed to the main function.
- *
- * status_signal: A status used eclusively by the threaded signal handler.
- * state: The state data used when processing the FSS data.
+ * flag: Flags passed to the main function.
+ * state: The state data used when processing the FSS data.
*
* range: A range used in conjunction with some buffer during processing.
*
#ifndef _di_fss_write_setting_t_
typedef struct {
uint32_t flag;
-
- f_status_t status_signal;
f_state_t state;
f_range_t range;
#define fss_write_setting_t_initialize \
{ \
fss_write_main_flag_none_d, \
- F_okay, \
macro_f_state_t_initialize_1(fss_write_allocation_large_d, fss_write_allocation_small_d, F_okay, 0, 0, &fll_program_standard_signal_handle, 0, 0, 0, 0), \
f_range_t_initialize, \
f_string_static_t_initialize, \
#if !defined(_di_fss_write_signal_check_) && defined(_di_thread_support_)
f_status_t fss_write_signal_check(fss_write_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % fss_write_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= fss_write_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, fss_write_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_fss_write_signal_handler_) && !defined(_di_thread_support_)
extern void fss_write_signal_handler(fss_write_main_t * const main);
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - flag: Flags passed to the main function.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state data used when processing the FSS data.
+ * - flag: Flags passed to the main function.
+ * - state: The state data used when processing the FSS data.
*
* - at: The position representing the "at" index.
* - line: The position representing the "line" index.
#ifndef _di_iki_read_setting_t_
typedef struct {
uint32_t flag;
-
- f_status_t status_signal;
f_state_t state;
f_number_unsigned_t at;
#define iki_read_setting_t_initialize \
{ \
iki_read_main_flag_none_d, \
- F_okay, \
macro_f_state_t_initialize_1(iki_read_allocation_large_d, iki_read_allocation_small_d, F_okay, 0, 0, 0, 0, 0, 0, 0), \
0, \
0, \
#if !defined(_di_iki_read_signal_check_) && defined(_di_thread_support_)
f_status_t iki_read_signal_check(iki_read_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % iki_read_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= iki_read_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, iki_read_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_iki_read_signal_handler_) && !defined(_di_thread_support_)
extern void iki_read_signal_handler(iki_read_main_t * const main);
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - flag: Flags passed to the main function.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state data used when processing the FSS data.
+ * - flag: Flags passed to the main function.
+ * - state: The state data used when processing the FSS data.
*
* - quote: This holds the quote used during processing.
*
#ifndef _di_iki_write_setting_t_
typedef struct {
uint16_t flag;
-
- f_status_t status_signal;
f_state_t state;
f_string_static_t quote;
#define iki_write_setting_t_initialize \
{ \
iki_write_main_flag_none_d, \
- F_okay, \
f_state_t_initialize, \
f_string_static_t_initialize, \
f_string_dynamics_t_initialize, \
#if !defined(_di_iki_write_signal_check_) && defined(_di_thread_support_)
f_status_t iki_write_signal_check(iki_write_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % iki_write_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= iki_write_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, iki_write_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_iki_write_signal_handler_) && !defined(_di_thread_support_)
extern void iki_write_signal_handler(iki_write_main_t * const main);
* This is passed to the program-specific main entry point to designate program settings.
* These program settings are often processed from the program arguments (often called the command line arguments).
*
- * flag: Flags passed to the main function.
- *
- * status_signal: A status used eclusively by the threaded signal handler.
- * state: The state data used when processing the FSS data.
+ * flag: Flags passed to the main function.
+ * state: The state data used when processing the FSS data.
*
* status_string_from: A pointer to the status string function (usually either fl_status_string_from() or fll_fss_status_string_from()).
* status_string_to: A pointer to the status string function (usually either f_status_string_to() or fll_fss_status_string_to()).
#ifndef _di_status_code_setting_t_
typedef struct {
uint16_t flag;
-
- f_status_t status_signal;
f_state_t state;
const f_string_static_t *program_name;
#define status_code_setting_t_initialize \
{ \
status_code_main_flag_none_d, \
- F_okay, \
f_state_t_initialize, \
0, \
0, \
#if !defined(_di_status_code_signal_check_) && defined(_di_thread_support_)
f_status_t status_code_signal_check(status_code_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % status_code_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= status_code_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, status_code_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_status_code_signal_handler_) && !defined(_di_thread_support_)
extern void status_code_signal_handler(status_code_main_t * const main);
* These program settings are often processed from the program arguments (often called the command line arguments).
*
* Properties:
- * - mode: The input/output mode (see utf8_modes_e).
- * - flag: Flags passed to the main function.
- *
- * - status_signal: A status used eclusively by the threaded signal handler.
- * - state: The state data used when processing the FSS data.
+ * - mode: The input/output mode (see utf8_modes_e).
+ * - flag: Flags passed to the main function.
+ * - state: The state data used when processing the FSS data.
*
* - valid: Designate the output context set for valid characters.
* - valid_not: Designate the output context set for invalid characters.
typedef struct {
uint8_t mode;
uint16_t flag;
-
- f_status_t status_signal;
f_state_t state;
f_color_set_t valid;
{ \
utf8_mode_from_bytesequence_e | utf8_mode_to_codepoint_e, \
utf8_main_flag_none_d, \
- F_okay, \
f_state_t_initialize, \
f_color_set_t_initialize, \
f_color_set_t_initialize, \
#if !defined(_di_utf8_signal_check_) && defined(_di_thread_support_)
f_status_t utf8_signal_check(utf8_main_t * const main) {
- if (!main || main->program.signal.id == -1) return F_false;
+ if (!main) return F_false;
+ if (main->program.signal_received) return F_true;
if (!((++main->program.signal_check) % utf8_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
+ if (F_status_set_fine(fll_program_standard_signal_received(&main->program)) == F_interrupt) {
fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
main->setting.state.status = F_status_set_error(F_interrupt);
if (!main) return;
- siginfo_t information;
- f_number_unsigned_t failsafe = 0;
-
- memset(&information, 0, sizeof(siginfo_t));
-
- main->program.signal_received = 0;
-
f_signal_set_empty(&main->program.signal.set);
f_signal_set_add(F_signal_abort, &main->program.signal.set);
f_signal_set_add(F_signal_broken_pipe, &main->program.signal.set);
f_signal_set_add(F_signal_quit, &main->program.signal.set);
f_signal_set_add(F_signal_termination, &main->program.signal.set);
- if (main->program.signal.id == -1) {
- main->setting.status_signal = f_signal_open(&main->program.signal);
-
- if (F_status_is_error(main->setting.status_signal)) {
- main->program.signal_received = F_signal_abort;
-
- return;
- }
- }
-
- do {
- memset(&information, 0, sizeof(siginfo_t));
-
- main->setting.status_signal = f_signal_wait(&main->program.signal.set, &information);
-
- if (F_status_is_error(main->setting.status_signal) && F_status_set_fine(main->setting.status_signal) != F_interrupt) {
- if (++failsafe >= utf8_signal_check_failsafe_d) break;
- }
-
- switch (information.si_signo) {
- case F_signal_abort:
- case F_signal_broken_pipe:
- case F_signal_hangup:
- case F_signal_interrupt:
- case F_signal_quit:
- case F_signal_termination:
- main->program.signal_received = information.si_signo;
-
- break;
- }
-
- failsafe = 0;
- main->setting.status_signal = F_okay;
-
- } while (!main->program.signal_received);
-
- f_signal_close(&main->program.signal);
+ fll_program_standard_signal_received_wait(&main->program, utf8_signal_check_failsafe_d);
- if (F_status_is_error(main->setting.status_signal)) {
+ if (F_status_is_error(main->program.signal_status) && F_status_set_fine(main->program.signal_status) != F_interrupt) {
main->program.signal_received = F_signal_abort;
}
}
* The main program and settings data.
*
* This alters main.program.signal_received, setting it to a received signal.
+ * This alters main.program.signal_status.
*
- * This alters main.setting.state.status:
- * Errors (with error bit) from: f_signal_open()
- * Errors (with error bit) from: f_signal_wait()
+ * This does not alter main.setting.state.status.
*
- * @see f_signal_close()
- * @see f_signal_open()
- * @see f_signal_wait()
+ * @see fll_program_standard_signal_received_wait()
*/
#if !defined(_di_utf8_signal_handler_) && !defined(_di_thread_support_)
extern void utf8_signal_handler(utf8_main_t * const main);