From 928bb81378ba50f086af5eb54327819751a523aa Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 31 Mar 2022 23:42:01 -0500 Subject: [PATCH] Update: Ensure all programs are handling signals, adding signal_received to fll_program_data_t. Make sure fll_program_data_t supports storing the signal. Move the commonly written functions that are pretty much identical across programs into fll_program: - fll_program_standard_signal_received() - fll_program_standard_signal_state() Increase standard signal check from 10000 to 20000. I really dislike the signal_check logic that exists purely as a work-around to the signal handling. Most likely the only way to do this nicely that is available without rewritting the kernel and the libc will be to implement threads. This will not be done for the 0.6.x versions and will likely happen for the 0.8.x versions. --- level_2/fll_program/c/program.c | 52 +++++++++++++++++ level_2/fll_program/c/program.h | 56 ++++++++++++++++++ level_2/fll_program/c/program/common.h | 48 +++++++++------- level_3/byte_dump/c/common.h | 2 +- level_3/byte_dump/c/private-byte_dump.c | 4 +- level_3/byte_dump/c/private-common.c | 35 +----------- level_3/byte_dump/c/private-common.h | 22 +------- level_3/control/c/private-common.c | 56 ------------------ level_3/control/c/private-common.h | 37 +----------- level_3/control/c/private-control.c | 2 +- level_3/control/c/private-print.c | 2 +- .../c/controller/private-controller_print.c | 2 +- .../controller/c/thread/private-thread_signal.c | 2 +- level_3/fake/c/common.h | 2 +- level_3/fake/c/fake.c | 12 +++- level_3/fake/c/private-build-load.c | 14 +++-- level_3/fake/c/private-build.c | 28 ++++++--- level_3/fake/c/private-common.c | 29 ---------- level_3/fake/c/private-common.h | 18 ------ level_3/fake/c/private-fake.c | 66 +++------------------- level_3/fake/c/private-fake.h | 34 ----------- level_3/fake/c/private-make-load_fakefile.c | 20 +++++-- level_3/fake/c/private-make-operate.c | 18 ++++-- level_3/fake/c/private-make-operate_process.c | 8 ++- level_3/fake/c/private-print.c | 6 +- level_3/fake/c/private-print.h | 4 +- level_3/firewall/c/common.h | 2 +- level_3/firewall/c/private-common.c | 2 +- level_3/fss_basic_list_read/c/common.h | 2 +- .../fss_basic_list_read/c/fss_basic_list_read.c | 8 ++- level_3/fss_basic_list_read/c/private-common.c | 35 +----------- level_3/fss_basic_list_read/c/private-common.h | 22 +------- level_3/fss_basic_list_read/c/private-read.c | 34 ++++++++--- level_3/fss_basic_list_write/c/common.h | 2 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 36 +++++++++--- level_3/fss_basic_list_write/c/private-common.c | 35 +----------- level_3/fss_basic_list_write/c/private-common.h | 22 +------- level_3/fss_basic_list_write/c/private-write.c | 14 +++-- level_3/fss_basic_read/c/common.h | 2 +- level_3/fss_basic_read/c/fss_basic_read.c | 8 ++- level_3/fss_basic_read/c/private-common.c | 35 +----------- level_3/fss_basic_read/c/private-common.h | 22 +------- level_3/fss_basic_read/c/private-read.c | 32 ++++++++--- level_3/fss_basic_write/c/common.h | 2 +- level_3/fss_basic_write/c/fss_basic_write.c | 36 +++++++++--- level_3/fss_basic_write/c/private-common.c | 35 +----------- level_3/fss_basic_write/c/private-common.h | 22 +------- level_3/fss_basic_write/c/private-write.c | 12 +++- level_3/fss_basic_write/c/private-write.h | 18 ------ level_3/fss_embedded_list_read/c/common.h | 2 +- .../c/fss_embedded_list_read.c | 4 +- level_3/fss_embedded_list_read/c/private-common.c | 35 +----------- level_3/fss_embedded_list_read/c/private-common.h | 22 +------- level_3/fss_embedded_list_read/c/private-read.c | 10 +++- level_3/fss_embedded_list_write/c/common.h | 2 +- .../c/fss_embedded_list_write.c | 36 +++++++++--- level_3/fss_embedded_list_write/c/private-common.c | 35 +----------- level_3/fss_embedded_list_write/c/private-common.h | 22 +------- level_3/fss_embedded_list_write/c/private-write.c | 28 ++++++--- level_3/fss_extended_list_read/c/common.h | 2 +- .../c/fss_extended_list_read.c | 8 ++- level_3/fss_extended_list_read/c/private-common.c | 35 +----------- level_3/fss_extended_list_read/c/private-common.h | 22 +------- level_3/fss_extended_list_read/c/private-read.c | 10 +++- level_3/fss_extended_list_write/c/common.h | 2 +- .../c/fss_extended_list_write.c | 36 +++++++++--- level_3/fss_extended_list_write/c/private-common.c | 33 +---------- level_3/fss_extended_list_write/c/private-common.h | 22 +------- level_3/fss_extended_list_write/c/private-write.c | 22 ++++++-- level_3/fss_extended_read/c/common.h | 2 +- level_3/fss_extended_read/c/fss_extended_read.c | 8 ++- level_3/fss_extended_read/c/private-common.c | 35 +----------- level_3/fss_extended_read/c/private-common.h | 22 +------- level_3/fss_extended_read/c/private-read.c | 10 +++- level_3/fss_extended_write/c/common.h | 2 +- level_3/fss_extended_write/c/fss_extended_write.c | 8 ++- level_3/fss_extended_write/c/private-common.c | 35 +----------- level_3/fss_extended_write/c/private-common.h | 22 +------- level_3/fss_extended_write/c/private-write.c | 10 +++- level_3/fss_identify/c/common.h | 2 +- level_3/fss_identify/c/fss_identify.c | 4 +- level_3/fss_identify/c/private-common.c | 35 +----------- level_3/fss_identify/c/private-common.h | 22 +------- level_3/fss_identify/c/private-identify.c | 4 +- level_3/fss_payload_read/c/common.h | 2 +- level_3/fss_payload_read/c/fss_payload_read.c | 8 ++- level_3/fss_payload_read/c/private-common.c | 35 +----------- level_3/fss_payload_read/c/private-common.h | 22 +------- level_3/fss_payload_read/c/private-read.c | 34 ++++++++--- level_3/fss_payload_write/c/common.h | 2 +- level_3/fss_payload_write/c/fss_payload_write.c | 36 +++++++++--- level_3/fss_payload_write/c/private-common.c | 35 +----------- level_3/fss_payload_write/c/private-common.h | 22 +------- level_3/fss_payload_write/c/private-write.c | 14 +++-- level_3/fss_status_code/c/common.h | 2 +- level_3/fss_status_code/c/fss_status_code.c | 12 +++- level_3/fss_status_code/c/private-common.c | 35 +----------- level_3/fss_status_code/c/private-common.h | 22 +------- level_3/iki_read/c/common.h | 2 +- level_3/iki_read/c/iki_read.c | 4 +- level_3/iki_read/c/private-common.c | 35 +----------- level_3/iki_read/c/private-common.h | 22 +------- level_3/iki_read/c/private-read.c | 10 ++-- level_3/iki_write/c/common.h | 2 +- level_3/iki_write/c/iki_write.c | 4 +- level_3/iki_write/c/private-common.c | 35 +----------- level_3/iki_write/c/private-common.h | 22 +------- level_3/status_code/c/common.h | 2 +- level_3/status_code/c/private-common.c | 35 +----------- level_3/status_code/c/private-common.h | 22 +------- level_3/status_code/c/status_code.c | 12 +++- level_3/utf8/c/common.h | 2 +- level_3/utf8/c/private-common.c | 29 ---------- level_3/utf8/c/private-common.h | 18 ------ level_3/utf8/c/private-print.c | 2 +- level_3/utf8/c/private-utf8.c | 4 +- level_3/utf8/c/private-utf8.h | 2 +- level_3/utf8/c/private-utf8_binary.c | 10 ++-- level_3/utf8/c/private-utf8_binary.h | 4 +- level_3/utf8/c/private-utf8_codepoint.c | 10 ++-- level_3/utf8/c/private-utf8_codepoint.h | 4 +- level_3/utf8/c/utf8.c | 18 +++--- level_3/utf8/c/utf8.h | 2 +- 123 files changed, 728 insertions(+), 1491 deletions(-) diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index a460303..0c9fe91 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -320,6 +320,58 @@ extern "C" { } #endif // _di_fll_program_standard_setup_ +#ifndef _di_fll_program_standard_signal_received_ + f_status_t fll_program_standard_signal_received(fll_program_data_t * const main) { + + if (main->signal.id == -1) { + return F_false; + } + + struct signalfd_siginfo information; + + memset(&information, 0, sizeof(struct signalfd_siginfo)); + + if (f_signal_read(main->signal, 0, &information) == F_signal) { + switch (information.ssi_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: + return information.ssi_signo; + } + } + + return F_false; + } +#endif // _di_fss_basic_read_signal_received_ + +#ifndef _di_fll_program_standard_signal_state_ + f_status_t fll_program_standard_signal_state(void * const state, void * const internal) { + + if (!state) { + return F_interrupt_not; + } + + f_state_t *state_ptr = (f_state_t *) state; + + if (!state_ptr->custom) { + return F_interrupt_not; + } + + fll_program_data_t *main = (fll_program_data_t *) state_ptr->custom; + + main->signal_received = fll_program_standard_signal_received(main); + + if (main->signal_received == F_signal_abort || main->signal_received == F_signal_broken_pipe || main->signal_received == F_signal_hangup || main->signal_received == F_signal_interrupt || main->signal_received == F_signal_quit || main->signal_received == F_signal_termination) { + return F_status_set_error(F_interrupt); + } + + return F_interrupt_not; + } +#endif // _di_fll_program_standard_signal_state_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index bbf1bf1..f44fdc2 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -401,6 +401,62 @@ extern "C" { extern f_status_t fll_program_standard_setup(f_signal_t * const signal); #endif // _di_fll_program_standard_setup_ +/** + * Check to see if a process signal is received. + * + * Only signals that are blocked via main.signal will be received. + * + * If no signals are blocked, then this always returns F_false. + * + * @param main + * The main program data. + * The main->signal must be used to designate blocked signals. + * + * @return + * A positive number representing a valid signal on signal received. + * F_false on no signal received. + * + * @see f_signal_read() + */ +#ifndef _di_fss_basic_read_signal_received_ + extern f_status_t fll_program_standard_signal_received(fll_program_data_t * const main); +#endif // _di_fss_basic_read_signal_received_ + +/** + * Standardized callback for checking for interrupts via the f_state_t interrupt callback. + * + * This only checks for the signals: + * - F_signal_abort + * - F_signal_broken_pipe + * - F_signal_hangup + * - F_signal_interrupt + * - F_signal_quit + * - F_signal_termination + * + * These signals may not be checked if they are not also blocked via the fll_program_data_t.signals variable. + * + * When one of the above signals is both blocked and received, then this calls fll_program_standard_signal_received(). + * + * @param state + * The state data. + * This must be of type (f_state_t *). + * + * When constructing the f_state_t variable, a fll_program_data_t pointer must be passed into the f_state_t.custom variable. + * This requires the state.custom variable to be of type (fll_program_data_t *). + * @param internal + * Not used. + * + * @return + * F_interrupt_not if not interrupted. + * + * F_interrupt (with error bit) if interrupted. + * + * @see fll_program_standard_signal_received() + */ +#ifndef _di_fll_program_standard_signal_state_ + extern f_status_t fll_program_standard_signal_state(void * const state, void * const internal); +#endif // _di_fll_program_standard_signal_state_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_2/fll_program/c/program/common.h b/level_2/fll_program/c/program/common.h index 90fa9e4..5876b39 100644 --- a/level_2/fll_program/c/program/common.h +++ b/level_2/fll_program/c/program/common.h @@ -35,34 +35,36 @@ extern "C" { * The umask() has design flaws as per specification that requires the umask be changed to read the value! * As a work-around, a umask variable is provided here so that umask() only ever need be called once. * - * child: Reserved for a child process, often representing the child return status or the child process ID. - * context: The color context. - * error: The output file for error printing. - * output: The output file for general printing. - * parameters: The state of pre-defined parameters passed to the program. - * pid: The PID of the program. - * process_pipe: Designate whether or not to process the input pipe. - * signal: The process signal management structure. - * signal_check: A counter used to map to for reducing the amount of actual signal check calls. - * umask: The umask settings, needed for avoiding calls to umask() to read the current umask. - * warning: The output file for warning printing. + * child: Reserved for a child process, often representing the child return status or the child process ID. + * context: The color context. + * error: The output file for error printing. + * output: The output file for general printing. + * parameters: The state of pre-defined parameters passed to the program. + * pid: The PID of the program. + * process_pipe: Designate whether or not to process the input pipe. + * signal: The process signal management structure. + * 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). + * umask: The umask settings, needed for avoiding calls to umask() to read the current umask. + * warning: The output file for warning printing. */ #ifndef _di_fll_program_data_t_ typedef struct { f_console_parameters_t parameters; - uint16_t signal_check; mode_t umask; pid_t pid; - bool process_pipe; int child; + bool process_pipe; + + int signal_received; + uint16_t signal_check; + f_signal_t signal; fl_print_t output; fl_print_t error; fl_print_t warning; - f_signal_t signal; - f_color_context_t context; } fll_program_data_t; @@ -72,23 +74,27 @@ extern "C" { 0, \ 0, \ 0, \ - 0, \ F_false, \ + 0, \ + 0, \ + f_signal_t_initialize, \ fl_print_t_initialize, \ macro_fl_print_t_initialize_error(), \ macro_fl_print_t_initialize_warning(), \ - f_signal_t_initialize, \ f_color_context_t_initialize, \ } - #define macro_fll_program_data_t_initialize(parameters, signal_check, process_pipe, output, error, warning, signal, context) { \ - parameters, \ - signal_check, \ + #define macro_fll_program_data_t_initialize(umask, pid, child, process_pipe, signal_received, signal_check, signal, output, error, warning, context) { \ + umask, \ + pid, \ + child, \ process_pipe, \ + signal_received, \ + signal_check, \ + signal, \ output, \ error, \ warning, \ - signal, \ context, \ } #endif // _di_fll_program_data_t_ diff --git a/level_3/byte_dump/c/common.h b/level_3/byte_dump/c/common.h index a75ef87..d9249c4 100644 --- a/level_3/byte_dump/c/common.h +++ b/level_3/byte_dump/c/common.h @@ -121,7 +121,7 @@ extern "C" { #define byte_dump_option_wide_d 0x1 - #define byte_dump_signal_check_d 10000 + #define byte_dump_signal_check_d 20000 #define BYTE_DUMP_character_wall_s "|" #define BYTE_DUMP_character_placeholder_s "␣" // Other likely choices: (substitute form 1: '␚', substitute form 2: '␦'). diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 99cf142..3ee16c4 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -60,7 +60,9 @@ extern "C" { for (;;) { if (!((++data->main->signal_check) % byte_dump_signal_check_d)) { - if (byte_dump_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + byte_dump_print_signal_received(data); + return F_status_set_error(F_interrupt); } diff --git a/level_3/byte_dump/c/private-common.c b/level_3/byte_dump/c/private-common.c index 6cad075..54d8b21 100644 --- a/level_3/byte_dump/c/private-common.c +++ b/level_3/byte_dump/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_byte_dump_print_signal_received_ - void byte_dump_print_signal_received(byte_dump_data_t * const data, const f_status_t signal) { + void byte_dump_print_signal_received(byte_dump_data_t * const data) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(data->main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); - fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, data->main->signal_received, data->main->context.set.notable); fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); funlockfile(data->main->warning.to.stream); } #endif // _di_byte_dump_print_signal_received_ -#ifndef _di_byte_dump_signal_received_ - f_status_t byte_dump_signal_received(byte_dump_data_t * const data) { - - if (data->main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(data->main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - byte_dump_print_signal_received(data, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_byte_dump_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/byte_dump/c/private-common.h b/level_3/byte_dump/c/private-common.h index ad8ade3..559d8af 100644 --- a/level_3/byte_dump/c/private-common.h +++ b/level_3/byte_dump/c/private-common.h @@ -98,31 +98,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_byte_dump_print_signal_received_ - extern void byte_dump_print_signal_received(byte_dump_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; + extern void byte_dump_print_signal_received(byte_dump_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_byte_dump_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_byte_dump_signal_received_ - extern f_status_t byte_dump_signal_received(byte_dump_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_byte_dump_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/control/c/private-common.c b/level_3/control/c/private-common.c index 9051a25..4c62cf9 100644 --- a/level_3/control/c/private-common.c +++ b/level_3/control/c/private-common.c @@ -61,62 +61,6 @@ extern "C" { } #endif // _di_control_data_delete_ -#ifndef _di_control_signal_received_ - f_status_t control_signal_received(const fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - control_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_control_signal_received_ - -#ifndef _di_control_signal_state_interrupt_fss_ - f_status_t control_signal_state_interrupt_fss(void * const state, void * const internal) { - - if (!state) { - return F_interrupt_not; - } - - f_state_t * const state_ptr = (f_state_t *) state; - - if (!state_ptr->custom) { - return F_interrupt_not; - } - - fll_program_data_t * const main = (fll_program_data_t *) state_ptr->custom; - - if (!((++main->signal_check) % control_signal_check_d)) { - if (control_signal_received(main)) { - return F_status_set_error(F_interrupt); - } - - main->signal_check = 0; - } - - return F_interrupt_not; - } -#endif // _di_control_signal_state_interrupt_fss_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/control/c/private-common.h b/level_3/control/c/private-common.h index bd47084..19b9ed8 100644 --- a/level_3/control/c/private-common.h +++ b/level_3/control/c/private-common.h @@ -30,7 +30,7 @@ extern "C" { #define control_default_buffer_limit_soft_large_d 2048 #define control_default_buffer_limit_soft_small_d 64 - #define control_signal_check_d 10000 + #define control_signal_check_d 20000 #define control_allocation_large_d 256 #define control_allocation_small_d 16 @@ -319,41 +319,6 @@ extern "C" { extern void control_data_delete(control_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_control_data_delete_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_control_signal_received_ - extern f_status_t control_signal_received(const fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_control_signal_received_ - -/** - * Callback passed to FSS functions for checking for interrupts. - * - * @param state - * The f_state_t data. - * @param internal - * Not used. - * - * @return - * F_interrupt_not if not interrupted. - * - * F_interrupt (with error bit) on receiving a terminate process signal, such as an interrupt signal. - */ -#ifndef _di_control_signal_state_interrupt_fss_ - extern f_status_t control_signal_state_interrupt_fss(void * const state, void * const internal) F_attribute_visibility_internal_d; -#endif // _di_control_signal_state_interrupt_fss_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index 7078f27..da49a2f 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -247,7 +247,7 @@ extern "C" { } { - f_state_t state = macro_f_state_t_initialize(control_allocation_large_d, control_allocation_small_d, 0, &control_signal_state_interrupt_fss, 0, (void *) main, 0); + f_state_t state = macro_f_state_t_initialize(control_allocation_large_d, control_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range_packet = macro_f_string_range_t_initialize2(data->cache.large.used); status = fll_fss_basic_list_read(data->cache.large, state, &range_packet, &data->cache.packet_objects, &data->cache.packet_contents, &data->cache.delimits, 0, 0); diff --git a/level_3/control/c/private-print.c b/level_3/control/c/private-print.c index 5b031dc..9acb7ec 100644 --- a/level_3/control/c/private-print.c +++ b/level_3/control/c/private-print.c @@ -344,7 +344,7 @@ extern "C" { #ifndef _di_control_print_signal_received_ void control_print_signal_received(const fll_program_data_t * const main, const f_status_t signal) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); diff --git a/level_3/controller/c/controller/private-controller_print.c b/level_3/controller/c/controller/private-controller_print.c index da77117..230c99e 100644 --- a/level_3/controller/c/controller/private-controller_print.c +++ b/level_3/controller/c/controller/private-controller_print.c @@ -48,7 +48,7 @@ extern "C" { #ifndef _di_controller_print_signal_received_ void controller_print_signal_received(controller_main_t * const main, const f_status_t signal) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); diff --git a/level_3/controller/c/thread/private-thread_signal.c b/level_3/controller/c/thread/private-thread_signal.c index 75cbc29..79e6f01 100644 --- a/level_3/controller/c/thread/private-thread_signal.c +++ b/level_3/controller/c/thread/private-thread_signal.c @@ -55,7 +55,7 @@ extern "C" { return F_interrupt_not; } - controller_state_interrupt_t *custom = (controller_state_interrupt_t *) state_ptr->custom; + fll_program_data_t *main = (fll_program_data_t *) state_ptr->custom; controller_thread_t *thread = custom->thread; if (!controller_thread_is_enabled(custom->is_normal, thread)) { diff --git a/level_3/fake/c/common.h b/level_3/fake/c/common.h index dec7ff9..1d5233c 100644 --- a/level_3/fake/c/common.h +++ b/level_3/fake/c/common.h @@ -264,7 +264,7 @@ extern "C" { fake_operation_skeleton_e, }; - #define fake_signal_check_d 10000 + #define fake_signal_check_d 500000 #define fake_signal_check_tiny_d 4 #define fake_signal_check_short_d 16 diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 91c76a5..3d61ebd 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -331,10 +331,16 @@ extern "C" { if (status == F_child) break; - if (F_status_set_fine(status) == F_interrupt || !(i % fake_signal_check_short_d) && fake_signal_received(&data)) { - status = F_status_set_error(F_interrupt); + if (F_status_set_fine(status) == F_interrupt || !(i % fake_signal_check_short_d)) { + if (fll_program_standard_signal_received(main)) { + fake_print_signal_received(&data); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + data->main->signal_check = 0; } if (F_status_is_error(status)) { diff --git a/level_3/fake/c/private-build-load.c b/level_3/fake/c/private-build-load.c index c269356..c5f8dff 100644 --- a/level_3/fake/c/private-build-load.c +++ b/level_3/fake/c/private-build-load.c @@ -75,7 +75,9 @@ extern "C" { if (F_status_is_error(*status)) return; - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); return; @@ -109,7 +111,7 @@ extern "C" { f_fss_delimits_t delimits = f_fss_delimits_t_initialize; { - f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fake_signal_state_interrupt_fss, 0, (void *) data, 0); + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data->main, 0); *status = fll_fss_extended_read(buffer, state, &range, &objects, &contents, 0, 0, &delimits, 0); } @@ -182,7 +184,9 @@ extern "C" { if (F_status_is_error(*status) && buffer.used) return; - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); return; @@ -1380,7 +1384,9 @@ extern "C" { if (F_status_is_error(*status)) return; - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); return; diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index c4c4f12..c3f5fa1 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -348,7 +348,9 @@ extern "C" { if (F_status_is_error(*status) || f_file_exists(file_stage) == F_true || *status == F_child) return; - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); return; @@ -391,10 +393,16 @@ extern "C" { for (f_array_length_t i = 0; i < files.used; ++i) { - if (!(i % fake_signal_check_short_d) && fake_signal_received(data)) { - *status = F_status_set_error(F_interrupt); + if (!(i % fake_signal_check_short_d)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); - break; + *status = F_status_set_error(F_interrupt); + + break; + } + + data->main->signal_check = 0; } if (!files.array[i].used) continue; @@ -703,7 +711,9 @@ extern "C" { f_string_dynamics_resize(0, &arguments); - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); } else if (*status != F_child) { @@ -805,7 +815,9 @@ extern "C" { #ifndef _di_fake_build_operate_ f_status_t fake_build_operate(fake_data_t * const data, const f_string_static_t setting_file) { - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + return F_status_set_error(F_interrupt); } @@ -1088,7 +1100,9 @@ extern "C" { if (F_status_is_error(*status)) return; - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); return; diff --git a/level_3/fake/c/private-common.c b/level_3/fake/c/private-common.c index 3e3271f..6013987 100644 --- a/level_3/fake/c/private-common.c +++ b/level_3/fake/c/private-common.c @@ -399,35 +399,6 @@ extern "C" { } #endif // _di_fake_make_data_delete_ -#ifndef _di_fake_signal_received_ - f_status_t fake_signal_received(fake_data_t * const data) { - - if (data->main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(data->main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fake_print_signal_received(data, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fake_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-common.h b/level_3/fake/c/private-common.h index 5648d80..01a712b 100644 --- a/level_3/fake/c/private-common.h +++ b/level_3/fake/c/private-common.h @@ -1735,24 +1735,6 @@ extern "C" { extern f_status_t fake_make_data_delete(fake_make_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fake_make_data_delete_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param data - * The program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fake_signal_received_ - extern f_status_t fake_signal_received(fake_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fake_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 1b277cd..442484a 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -48,7 +48,9 @@ extern "C" { *status = fll_execute_program(program, arguments, ¶meter, 0, (void *) &return_code); - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + *status = F_status_set_error(F_interrupt); return 0; @@ -95,7 +97,9 @@ extern "C" { char *name_function = "f_file_exists"; f_status_t status = F_none; - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + return F_status_set_error(F_interrupt); } @@ -506,64 +510,12 @@ extern "C" { } #endif // _di_fake_process_console_parameters_ -#ifndef _di_fake_signal_state_interrupt_fss_ - f_status_t fake_signal_state_interrupt_fss(void * const state, void * const internal) { - - if (!state) { - return F_interrupt_not; - } - - f_state_t * const state_ptr = (f_state_t *) state; - - if (!state_ptr->custom) { - return F_interrupt_not; - } - - fake_data_t * const data = (fake_data_t *) state_ptr->custom; - - if (!((++data->main->signal_check) % fake_signal_check_d)) { - if (fake_signal_received(data)) { - return F_status_set_error(F_interrupt); - } - - data->main->signal_check = 0; - } - - return F_interrupt_not; - } -#endif // _di_fake_signal_state_interrupt_fss_ - -#ifndef _di_fake_signal_state_interrupt_iki_ - f_status_t fake_signal_state_interrupt_iki(void * const state, void * const internal) { - - if (!state) { - return F_interrupt_not; - } - - f_state_t * const state_ptr = (f_state_t *) state; - - if (!state_ptr->custom) { - return F_interrupt_not; - } - - fake_data_t * const data = (fake_data_t *) state_ptr->custom; - - if (!((++data->main->signal_check) % fake_signal_check_d)) { - if (fake_signal_received(data)) { - return F_status_set_error(F_interrupt); - } - - data->main->signal_check = 0; - } - - return F_interrupt_not; - } -#endif // _di_fake_signal_state_interrupt_iki_ - #ifndef _di_fake_validate_directories_ f_status_t fake_validate_parameter_directories(fake_data_t * const data) { - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + return F_status_set_error(F_interrupt); } diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index 2692b94..77e5f73 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -75,40 +75,6 @@ extern "C" { #endif // _di_validate_console_parameters_ /** - * Callback passed to FSS functions for checking for interrupts. - * - * @param state - * The f_state_t data. - * @param internal - * Not used. - * - * @return - * F_interrupt_not if not interrupted. - * - * F_interrupt (with error bit) on receiving a terminate process signal, such as an interrupt signal. - */ -#ifndef _di_fake_signal_state_interrupt_fss_ - extern f_status_t fake_signal_state_interrupt_fss(void * const state, void * const internal) F_attribute_visibility_internal_d; -#endif // _di_fake_signal_state_interrupt_fss_ - -/** - * Callback passed to IKI functions for checking for interrupts. - * - * @param state - * The f_state_t data. - * @param internal - * Not used. - * - * @return - * F_interrupt_not if not interrupted. - * - * F_interrupt (with error bit) on receiving a terminate process signal, such as an interrupt signal. - */ -#ifndef _di_fake_signal_state_interrupt_iki_ - extern f_status_t fake_signal_state_interrupt_iki(void * const state, void * const internal) F_attribute_visibility_internal_d; -#endif // _di_fake_signal_state_interrupt_iki_ - -/** * Validate directories and print any relating error messages. * * This should not be called for skeleton as in that case the directories probably do not exist. diff --git a/level_3/fake/c/private-make-load_fakefile.c b/level_3/fake/c/private-make-load_fakefile.c index a1af103..4a61715 100644 --- a/level_3/fake/c/private-make-load_fakefile.c +++ b/level_3/fake/c/private-make-load_fakefile.c @@ -19,7 +19,9 @@ extern "C" { if (F_status_is_error(*status)) return; - if (fake_signal_received(data_make->data)) { + if (fll_program_standard_signal_received(data_make->main)) { + fake_print_signal_received(data_make->data); + *status = F_status_set_error(F_interrupt); return; @@ -53,7 +55,7 @@ extern "C" { f_fss_comments_t comments = f_fss_comments_t_initialize; { - f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fake_signal_state_interrupt_fss, 0, (void *) data_make->data, 0); + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data_make->data, 0); *status = fll_fss_basic_list_read(data_make->buffer, state, &range, &list_objects, &list_contents, &delimits, 0, &comments); } @@ -86,7 +88,7 @@ extern "C" { f_fss_set_t settings = f_fss_set_t_initialize; - f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fake_signal_state_interrupt_fss, 0, (void *) data_make->data, 0); + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fll_program_standard_signal_state, (void *) data_make->data, 0); if (list_objects.used > data_make->fakefile.size) { macro_f_fss_nameds_t_resize((*status), data_make->fakefile, list_objects.used); @@ -108,10 +110,16 @@ extern "C" { for (f_array_length_t i = 0; i < list_objects.used; ++i) { - if (!(i % fake_signal_check_short_d) && fake_signal_received(data_make->data)) { - *status = F_status_set_error(F_interrupt); + if (!(i % fake_signal_check_short_d)) { + if (fll_program_standard_signal_received(data_make->main)) { + fake_print_signal_received(data_make->data); - break; + *status = F_status_set_error(F_interrupt); + + break; + } + + data_make->main->signal_check = 0; } if (fl_string_dynamic_partial_compare_string(fake_make_section_settings_s.string, data_make->buffer, fake_make_section_settings_s.used, list_objects.array[i]) == F_equal_to) { diff --git a/level_3/fake/c/private-make-operate.c b/level_3/fake/c/private-make-operate.c index 59e6de4..a455f60 100644 --- a/level_3/fake/c/private-make-operate.c +++ b/level_3/fake/c/private-make-operate.c @@ -20,7 +20,9 @@ extern "C" { #ifndef _di_fake_make_operate_ f_status_t fake_make_operate(fake_data_t * const data) { - if (fake_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fake_print_signal_received(data); + return F_status_set_error(F_interrupt); } @@ -163,7 +165,7 @@ extern "C" { f_iki_data_t iki_data = f_iki_data_t_initialize; - f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fake_signal_state_interrupt_iki, 0, (void *) data_make->data, 0); + f_state_t state = macro_f_state_t_initialize(fake_common_allocation_large_d, fake_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data_make->data, 0); f_string_range_t range = f_string_range_t_initialize; f_string_map_multis_t *parameter = &data_make->setting_make.parameter; @@ -1045,10 +1047,16 @@ extern "C" { state_process.operation_previous = state_process.operation; state_process.operation = 0; - if (!(i % fake_signal_check_short_d) && fake_signal_received(data_make->data)) { - *status = F_status_set_error(F_interrupt); + if (!(i % fake_signal_check_short_d)) { + if (fll_program_standard_signal_received(data_make->main)) { + fake_print_signal_received(data_make->data); - break; + *status = F_status_set_error(F_interrupt); + + break; + } + + data_make->main->signal_check = 0; } for (j = 0; j < fake_make_operation_total_d; ++j) { diff --git a/level_3/fake/c/private-make-operate_process.c b/level_3/fake/c/private-make-operate_process.c index 3a0c7f5..2e28373 100644 --- a/level_3/fake/c/private-make-operate_process.c +++ b/level_3/fake/c/private-make-operate_process.c @@ -505,7 +505,9 @@ extern "C" { #ifndef _di_fake_make_operate_process_execute_ f_status_t fake_make_operate_process_execute(fake_make_data_t * const data_make, const f_string_static_t program, const f_string_statics_t arguments, const bool as_shell) { - if (fake_signal_received(data_make->data)) { + if (fll_program_standard_signal_received(data_make->main)) { + fake_print_signal_received(data_make->data); + return F_status_set_error(F_interrupt); } @@ -559,7 +561,9 @@ extern "C" { status = fll_execute_program(program, arguments, ¶meter, 0, (void *) &return_code); - if (fake_signal_received(data_make->data)) { + if (fll_program_standard_signal_received(data_make->main)) { + fake_print_signal_received(data_make->data); + return F_status_set_error(F_interrupt); } diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 6ceb408..b895d4e 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -471,9 +471,9 @@ extern "C" { #endif // _di_fake_print_message_section_operation_unknown_ #ifndef _di_fake_print_signal_received_ - void fake_print_signal_received(fake_data_t * const data, const f_status_t signal) { + void fake_print_signal_received(fake_data_t * const data) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); @@ -481,7 +481,7 @@ extern "C" { flockfile(data->main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); - fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, data->main->signal_received, data->main->context.set.notable); fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); funlockfile(data->main->warning.to.stream); diff --git a/level_3/fake/c/private-print.h b/level_3/fake/c/private-print.h index 7c2453c..fb72e05 100644 --- a/level_3/fake/c/private-print.h +++ b/level_3/fake/c/private-print.h @@ -285,8 +285,6 @@ extern "C" { * * @param data * The program data. - * @param signal - * The signal received. * * @see flockfile() * @see funlockfile() @@ -294,7 +292,7 @@ extern "C" { * @see fl_print_format() */ #ifndef _di_fake_print_signal_received_ - extern void fake_print_signal_received(fake_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fake_print_signal_received(fake_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fake_print_signal_received_ /** diff --git a/level_3/firewall/c/common.h b/level_3/firewall/c/common.h index f16180a..c6d648b 100644 --- a/level_3/firewall/c/common.h +++ b/level_3/firewall/c/common.h @@ -109,7 +109,7 @@ extern "C" { * The program defines. */ #ifndef _di_firewall_defines_ - #define firewall_signal_check_d 10000 + #define firewall_signal_check_d 20000 #endif // _di_firewall_defines_ /** diff --git a/level_3/firewall/c/private-common.c b/level_3/firewall/c/private-common.c index 902879b..dadb9e2 100644 --- a/level_3/firewall/c/private-common.c +++ b/level_3/firewall/c/private-common.c @@ -88,7 +88,7 @@ void firewall_print_error_on_unhandled_for_file(const fl_print_t output, const c #ifndef _di_firewall_print_signal_received_ void firewall_print_signal_received(firewall_data_t * const data, const f_status_t signal) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); diff --git a/level_3/fss_basic_list_read/c/common.h b/level_3/fss_basic_list_read/c/common.h index e10a565..1159184 100644 --- a/level_3/fss_basic_list_read/c/common.h +++ b/level_3/fss_basic_list_read/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_basic_list_read_defines_ - #define fss_basic_list_read_signal_check_d 10000 + #define fss_basic_list_read_signal_check_d 20000 #define FSS_BASIC_LIST_READ_pipe_name_s "(pipe)" diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index a4abf28..b976543 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -344,7 +344,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_list_read_parameter_delimit_e].values.used; ++i) { if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -537,7 +539,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_basic_list_read/c/private-common.c b/level_3/fss_basic_list_read/c/private-common.c index f706c11..7f1e7e8 100644 --- a/level_3/fss_basic_list_read/c/private-common.c +++ b/level_3/fss_basic_list_read/c/private-common.c @@ -57,9 +57,9 @@ extern "C" { #endif // _di_fss_basic_list_read_depths_resize_ #ifndef _di_fss_basic_list_read_print_signal_received_ - void fss_basic_list_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_basic_list_read_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -67,42 +67,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_basic_list_read_print_signal_received_ -#ifndef _di_fss_basic_list_read_signal_received_ - f_status_t fss_basic_list_read_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_basic_list_read_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_basic_list_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_list_read/c/private-common.h b/level_3/fss_basic_list_read/c/private-common.h index 3d85cdf..0b07209 100644 --- a/level_3/fss_basic_list_read/c/private-common.h +++ b/level_3/fss_basic_list_read/c/private-common.h @@ -257,31 +257,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_basic_list_read_print_signal_received_ - extern void fss_basic_list_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_basic_list_read_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_basic_list_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_basic_list_read_signal_received_ - extern f_status_t fss_basic_list_read_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index af5c725..a847f9f 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -87,7 +87,9 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -173,7 +175,9 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -242,7 +246,7 @@ extern "C" { #ifndef _di_fss_basic_list_read_load_ f_status_t fss_basic_list_read_load(fll_program_data_t * const main, fss_basic_list_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize(fss_basic_list_read_common_allocation_large_d, fss_basic_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_basic_list_read_common_allocation_large_d, fss_basic_list_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; @@ -352,7 +356,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -398,7 +404,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -499,7 +507,9 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -580,7 +590,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -618,7 +630,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -733,7 +747,9 @@ extern "C" { if (!names[at]) continue; if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fss_basic_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } diff --git a/level_3/fss_basic_list_write/c/common.h b/level_3/fss_basic_list_write/c/common.h index e37b7ce..3c56170 100644 --- a/level_3/fss_basic_list_write/c/common.h +++ b/level_3/fss_basic_list_write/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_basic_list_write_defines_ - #define fss_basic_list_write_signal_check_d 10000 + #define fss_basic_list_write_signal_check_d 20000 #define FSS_BASIC_LIST_WRITE_pipe_name_s "(pipe)" diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index eb5a090..94107bc 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -421,10 +421,16 @@ extern "C" { if (main->parameters.array[fss_basic_list_write_parameter_object_e].result == f_console_result_additional_e) { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_list_write_parameter_object_e].values.used; ++i) { - if (fss_basic_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } index = main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]; @@ -436,10 +442,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_list_write_parameter_content_e].values.used; ++i) { - if (fss_basic_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } index = main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]; @@ -452,10 +464,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_list_write_parameter_object_e].values.used; ++i) { - if (fss_basic_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } index = main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]; diff --git a/level_3/fss_basic_list_write/c/private-common.c b/level_3/fss_basic_list_write/c/private-common.c index c1b3834..d62960d 100644 --- a/level_3/fss_basic_list_write/c/private-common.c +++ b/level_3/fss_basic_list_write/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_basic_list_write_print_signal_received_ - void fss_basic_list_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_basic_list_write_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_basic_list_write_print_signal_received_ -#ifndef _di_fss_basic_list_write_signal_received_ - f_status_t fss_basic_list_write_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_basic_list_write_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_basic_list_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_list_write/c/private-common.h b/level_3/fss_basic_list_write/c/private-common.h index 87aa39a..33d9924 100644 --- a/level_3/fss_basic_list_write/c/private-common.h +++ b/level_3/fss_basic_list_write/c/private-common.h @@ -29,31 +29,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_basic_list_write_print_signal_received_ - extern void fss_basic_list_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_basic_list_write_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_basic_list_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_basic_list_write_signal_received_ - extern f_status_t fss_basic_list_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_list_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_list_write/c/private-write.c b/level_3/fss_basic_list_write/c/private-write.c index 5dfedd5..5c9b440 100644 --- a/level_3/fss_basic_list_write/c/private-write.c +++ b/level_3/fss_basic_list_write/c/private-write.c @@ -65,7 +65,7 @@ extern "C" { f_status_t fss_basic_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t * const buffer) { f_status_t status = F_none; - f_state_t state = macro_f_state_t_initialize(fss_basic_list_write_common_allocation_large_d, fss_basic_list_write_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_basic_list_write_common_allocation_large_d, fss_basic_list_write_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -167,10 +167,16 @@ extern "C" { for (;;) { - if (fss_basic_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } if (range.start > range.stop) { diff --git a/level_3/fss_basic_read/c/common.h b/level_3/fss_basic_read/c/common.h index 8a843bb..53391a5 100644 --- a/level_3/fss_basic_read/c/common.h +++ b/level_3/fss_basic_read/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_basic_read_defines_ - #define fss_basic_read_signal_check_d 10000 + #define fss_basic_read_signal_check_d 20000 #define FSS_BASIC_READ_pipe_name_s "(pipe)" diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index f4aac89..c86fb99 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -343,7 +343,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_read_parameter_delimit_e].values.used; ++i) { if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -544,7 +546,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + status = F_status_set_error(F_signal); break; diff --git a/level_3/fss_basic_read/c/private-common.c b/level_3/fss_basic_read/c/private-common.c index 37a08b9..d89a23a 100644 --- a/level_3/fss_basic_read/c/private-common.c +++ b/level_3/fss_basic_read/c/private-common.c @@ -56,9 +56,9 @@ extern "C" { #endif // _di_fss_basic_read_depths_resize_ #ifndef _di_fss_basic_read_print_signal_received_ - void fss_basic_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_basic_read_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -66,42 +66,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_basic_read_print_signal_received_ -#ifndef _di_fss_basic_read_signal_received_ - f_status_t fss_basic_read_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_basic_read_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_basic_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index bab1c6d..9ad7992 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -252,31 +252,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_basic_read_print_signal_received_ - extern void fss_basic_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_basic_read_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_basic_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_basic_read_signal_received_ - extern f_status_t fss_basic_read_signal_received(fll_program_data_t * const main); -#endif // _di_fss_basic_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 325fbe0..d4a6c67 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -64,7 +64,9 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -150,7 +152,9 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -219,7 +223,7 @@ extern "C" { #ifndef _di_fss_basic_read_load_ f_status_t fss_basic_read_load(fll_program_data_t * const main, fss_basic_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_basic_read_common_allocation_large_d, fss_basic_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits.used = 0; @@ -228,6 +232,12 @@ extern "C" { const f_status_t status = fll_fss_basic_read(data->buffer, state, &input, &data->objects, &data->contents, &data->quotes, &data->delimits, 0); if (F_status_is_error(status)) { + if (F_status_set_fine(status) == F_interrupt) { + fss_basic_read_print_signal_received(main); + + return status; + } + const f_string_static_t file_name = fss_basic_read_file_identify(input.start, data->files); fll_error_file_print(main->error, F_status_set_fine(status), "fll_fss_basic_read", F_true, file_name, f_file_operation_process_s, fll_error_file_type_file_e); @@ -367,7 +377,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -448,7 +460,9 @@ extern "C" { if (!names[at]) continue; if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -479,7 +493,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -628,7 +644,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fss_basic_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } diff --git a/level_3/fss_basic_write/c/common.h b/level_3/fss_basic_write/c/common.h index a9afd71..083f73a 100644 --- a/level_3/fss_basic_write/c/common.h +++ b/level_3/fss_basic_write/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_basic_write_defines_ - #define fss_basic_write_signal_check_d 10000 + #define fss_basic_write_signal_check_d 20000 #define FSS_BASIC_WRITE_pipe_name_s "(pipe)" diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 9f35b21..6f132d3 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -418,10 +418,16 @@ extern "C" { if (main->parameters.array[fss_basic_write_parameter_object_e].result == f_console_result_additional_e) { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_write_parameter_object_e].values.used; ++i) { - if (fss_basic_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_basic_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_write_parameter_object_e].values.array[i]], 0, &buffer); @@ -431,10 +437,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_write_parameter_content_e].values.used; ++i) { - if (fss_basic_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_basic_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_basic_write_parameter_content_e].values.array[i]], &buffer); @@ -445,10 +457,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_write_parameter_object_e].values.used; ++i) { - if (fss_basic_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_basic_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_basic_write_parameter_content_e].values.array[i]], &buffer); diff --git a/level_3/fss_basic_write/c/private-common.c b/level_3/fss_basic_write/c/private-common.c index 63c624a..f3fb15e 100644 --- a/level_3/fss_basic_write/c/private-common.c +++ b/level_3/fss_basic_write/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_basic_write_print_signal_received_ - void fss_basic_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_basic_write_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_basic_write_print_signal_received_ -#ifndef _di_fss_basic_write_signal_received_ - f_status_t fss_basic_write_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_basic_write_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_basic_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_write/c/private-common.h b/level_3/fss_basic_write/c/private-common.h index 3eeac9c..1faf1ac 100644 --- a/level_3/fss_basic_write/c/private-common.h +++ b/level_3/fss_basic_write/c/private-common.h @@ -29,31 +29,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_basic_write_print_signal_received_ - extern void fss_basic_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_basic_write_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_basic_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_basic_write_signal_received_ - extern f_status_t fss_basic_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_basic_write/c/private-write.c b/level_3/fss_basic_write/c/private-write.c index bdee78f..a231e4a 100644 --- a/level_3/fss_basic_write/c/private-write.c +++ b/level_3/fss_basic_write/c/private-write.c @@ -65,7 +65,7 @@ extern "C" { f_status_t fss_basic_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t *buffer) { f_status_t status = F_none; - f_state_t state = macro_f_state_t_initialize(fss_basic_write_common_allocation_large_d, fss_basic_write_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_basic_write_common_allocation_large_d, fss_basic_write_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -171,8 +171,14 @@ extern "C" { for (;;) { - if (fss_basic_write_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_write_print_signal_received(main); + + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (range.start > range.stop) { diff --git a/level_3/fss_basic_write/c/private-write.h b/level_3/fss_basic_write/c/private-write.h index e8c09e4..74f8c1b 100644 --- a/level_3/fss_basic_write/c/private-write.h +++ b/level_3/fss_basic_write/c/private-write.h @@ -94,24 +94,6 @@ extern "C" { extern f_status_t fss_basic_write_process_pipe(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer) F_attribute_visibility_internal_d; #endif // _di_fss_basic_write_process_pipe_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_basic_write_signal_received_ - extern f_status_t fss_basic_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_basic_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_read/c/common.h b/level_3/fss_embedded_list_read/c/common.h index d526eaf..109ddcc 100644 --- a/level_3/fss_embedded_list_read/c/common.h +++ b/level_3/fss_embedded_list_read/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_embedded_list_read_defines_ - #define fss_embedded_list_read_signal_check_d 10000 + #define fss_embedded_list_read_signal_check_d 20000 #define FSS_EMBEDDED_LIST_READ_pipe_name_s "(pipe)" diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 27d91d5..6b9a3a7 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -435,7 +435,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { - if (fss_embedded_list_read_signal_received(&data)) { + if (fll_program_standard_signal_received(main)) { + fss_embedded_list_read_print_signal_received(&data); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_embedded_list_read/c/private-common.c b/level_3/fss_embedded_list_read/c/private-common.c index 2417b65..d064522 100644 --- a/level_3/fss_embedded_list_read/c/private-common.c +++ b/level_3/fss_embedded_list_read/c/private-common.c @@ -17,9 +17,9 @@ extern "C" { #endif // _di_fss_embedded_list_read_data_delete_ #ifndef _di_fss_embedded_list_read_print_signal_received_ - void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data, const f_status_t signal) { + void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); @@ -27,42 +27,13 @@ extern "C" { flockfile(data->main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); - fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, data->main->signal_received, data->main->context.set.notable); fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); funlockfile(data->main->warning.to.stream); } #endif // _di_fss_embedded_list_read_print_signal_received_ -#ifndef _di_fss_embedded_list_read_signal_received_ - f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_data_t * const data) { - - if (data->main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(data->main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_embedded_list_read_print_signal_received(data, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_embedded_list_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_read/c/private-common.h b/level_3/fss_embedded_list_read/c/private-common.h index 5b1f54a..4f9ee77 100644 --- a/level_3/fss_embedded_list_read/c/private-common.h +++ b/level_3/fss_embedded_list_read/c/private-common.h @@ -197,31 +197,11 @@ extern "C" { * * @param data * The program data. - * @param signal - * The signal received. */ #ifndef _di_fss_embedded_list_read_print_signal_received_ - extern void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param data - * The program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_embedded_list_read_signal_received_ - extern f_status_t fss_embedded_list_read_signal_received(fss_embedded_list_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_fss_embedded_list_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 8c531e2..a039bec 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -130,7 +130,9 @@ extern "C" { for (i = 0; i < values_total; ++i) { if (!((++data->main->signal_check) % fss_embedded_list_read_signal_check_d)) { - if (fss_embedded_list_read_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fss_embedded_list_read_print_signal_received(data); + return F_status_set_error(F_interrupt); } @@ -243,7 +245,7 @@ extern "C" { f_status_t status = F_none; { - f_state_t state = macro_f_state_t_initialize(fss_embedded_list_read_common_allocation_large_d, fss_embedded_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_embedded_list_read_common_allocation_large_d, fss_embedded_list_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data->main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); objects_delimits->used = 0; @@ -559,7 +561,9 @@ extern "C" { if (skip[i]) continue; if (!((++data->main->signal_check) % fss_embedded_list_read_signal_check_d)) { - if (fss_embedded_list_read_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + fss_embedded_list_read_print_signal_received(data); + return F_status_set_error(F_interrupt); } diff --git a/level_3/fss_embedded_list_write/c/common.h b/level_3/fss_embedded_list_write/c/common.h index 7db1290..3b3dad9 100644 --- a/level_3/fss_embedded_list_write/c/common.h +++ b/level_3/fss_embedded_list_write/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_embedded_list_write_defines_ - #define fss_embedded_list_write_signal_check_d 10000 + #define fss_embedded_list_write_signal_check_d 20000 #define FSS_EMBEDDED_LIST_WRITE_pipe_name_s "(pipe)" diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index 0d37154..f61d362 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -425,10 +425,16 @@ extern "C" { if (main->parameters.array[fss_embedded_list_write_parameter_object_e].result == f_console_result_additional_e) { for (f_array_length_t i = 0; i < main->parameters.array[fss_embedded_list_write_parameter_object_e].values.used; ++i) { - if (fss_embedded_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_embedded_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_embedded_list_write_process(main, output, quote, &argv[main->parameters.array[fss_embedded_list_write_parameter_object_e].values.array[i]], 0, 0, &buffer); @@ -438,10 +444,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_embedded_list_write_parameter_content_e].values.used; ++i) { - if (fss_embedded_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_embedded_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_embedded_list_write_process_parameter_ignore(main, main->parameters.array[fss_embedded_list_write_parameter_content_e].locations, i, &ignore); @@ -455,10 +467,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_embedded_list_write_parameter_object_e].values.used; ++i) { - if (fss_embedded_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_embedded_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_embedded_list_write_process_parameter_ignore(main, main->parameters.array[fss_embedded_list_write_parameter_content_e].locations, i, &ignore); diff --git a/level_3/fss_embedded_list_write/c/private-common.c b/level_3/fss_embedded_list_write/c/private-common.c index f0dc8a7..656ffae 100644 --- a/level_3/fss_embedded_list_write/c/private-common.c +++ b/level_3/fss_embedded_list_write/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_embedded_list_write_print_signal_received_ - void fss_embedded_list_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_embedded_list_write_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_embedded_list_write_print_signal_received_ -#ifndef _di_fss_embedded_list_write_signal_received_ - f_status_t fss_embedded_list_write_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_embedded_list_write_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_embedded_list_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_write/c/private-common.h b/level_3/fss_embedded_list_write/c/private-common.h index a2920f5..32c8d03 100644 --- a/level_3/fss_embedded_list_write/c/private-common.h +++ b/level_3/fss_embedded_list_write/c/private-common.h @@ -30,31 +30,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_embedded_list_write_print_signal_received_ - extern void fss_embedded_list_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_embedded_list_write_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_embedded_list_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_embedded_list_write_signal_received_ - extern f_status_t fss_embedded_list_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_embedded_list_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_embedded_list_write/c/private-write.c b/level_3/fss_embedded_list_write/c/private-write.c index 9ea6f9f..8265677 100644 --- a/level_3/fss_embedded_list_write/c/private-write.c +++ b/level_3/fss_embedded_list_write/c/private-write.c @@ -65,7 +65,7 @@ extern "C" { f_status_t fss_embedded_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, const f_string_ranges_t *ignore, f_string_dynamic_t *buffer) { f_status_t status = F_none; - f_state_t state = macro_f_state_t_initialize(fss_embedded_list_write_common_allocation_large_d, fss_embedded_list_write_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_embedded_list_write_common_allocation_large_d, fss_embedded_list_write_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -169,12 +169,18 @@ extern "C" { for (;;) { - if (fss_embedded_list_write_signal_received(main)) { - f_string_dynamic_resize(0, &block); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); + if (!((++main->signal_check) % fss_embedded_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_embedded_list_write_print_signal_received(main); - return F_status_set_error(F_interrupt); + f_string_dynamic_resize(0, &block); + f_string_dynamic_resize(0, &object); + f_string_dynamic_resize(0, &content); + + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (range.start > range.stop) { @@ -379,8 +385,14 @@ extern "C" { for (; i < main->parameters.array[fss_embedded_list_write_parameter_ignore_e].locations.used; ++i) { - if (fss_embedded_list_write_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_embedded_list_write_print_signal_received(main); + + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } l = main->parameters.array[fss_embedded_list_write_parameter_ignore_e].locations.array[i]; diff --git a/level_3/fss_extended_list_read/c/common.h b/level_3/fss_extended_list_read/c/common.h index c431d35..5f5f681 100644 --- a/level_3/fss_extended_list_read/c/common.h +++ b/level_3/fss_extended_list_read/c/common.h @@ -69,7 +69,7 @@ extern "C" { * The program defines. */ #ifndef _di_fss_extended_list_read_defines_ - #define fss_extended_list_read_signal_check_d 10000 + #define fss_extended_list_read_signal_check_d 20000 #define FSS_EXTENDED_LIST_READ_pipe_name_s "(pipe)" diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 4e6bcd0..404b298 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -343,7 +343,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.used; ++i) { if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fss_extended_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -544,7 +546,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fss_extended_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_extended_list_read/c/private-common.c b/level_3/fss_extended_list_read/c/private-common.c index 083e43b..688b59e 100644 --- a/level_3/fss_extended_list_read/c/private-common.c +++ b/level_3/fss_extended_list_read/c/private-common.c @@ -57,9 +57,9 @@ extern "C" { #endif // _di_fss_extended_list_read_depths_resize_ #ifndef _di_fss_extended_list_read_print_signal_received_ - void fss_extended_list_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_extended_list_read_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -67,42 +67,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_extended_list_read_print_signal_received_ -#ifndef _di_fss_extended_list_read_signal_received_ - f_status_t fss_extended_list_read_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_extended_list_read_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_extended_list_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h index 238f36f..18cde8d 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -258,31 +258,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_extended_list_read_print_signal_received_ - extern void fss_extended_list_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_extended_list_read_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_extended_list_read_signal_received_ - extern f_status_t fss_extended_list_read_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index 72e338a..aa47754 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -87,7 +87,9 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fss_extended_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -173,7 +175,9 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { - if (fss_extended_list_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -241,7 +245,7 @@ extern "C" { #ifndef _di_fss_extended_list_read_load_ f_status_t fss_extended_list_read_load(fll_program_data_t * const main, fss_extended_list_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_extended_list_read_common_allocation_large_d, fss_extended_list_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; diff --git a/level_3/fss_extended_list_write/c/common.h b/level_3/fss_extended_list_write/c/common.h index 594f2fe..8d5800f 100644 --- a/level_3/fss_extended_list_write/c/common.h +++ b/level_3/fss_extended_list_write/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_extended_list_write_defines_ - #define fss_extended_list_write_signal_check_d 10000 + #define fss_extended_list_write_signal_check_d 20000 #define FSS_EXTENDED_LIST_WRITE_pipe_name_s "(pipe)" diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 71621e2..9fed184 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -424,10 +424,16 @@ extern "C" { if (main->parameters.array[fss_extended_list_write_parameter_object_e].result == f_console_result_additional_e) { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_list_write_parameter_object_e].values.used; ++i) { - if (fss_extended_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_extended_list_write_process(main, output, quote, &argv[main->parameters.array[fss_extended_list_write_parameter_object_e].values.array[i]], 0, 0, &buffer); @@ -437,10 +443,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_list_write_parameter_content_e].values.used; ++i) { - if (fss_extended_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_extended_list_write_process_parameter_ignore(main, main->parameters.array[fss_extended_list_write_parameter_content_e].locations, i, &ignore); @@ -454,10 +466,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_list_write_parameter_object_e].values.used; ++i) { - if (fss_extended_list_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_extended_list_write_process_parameter_ignore(main, main->parameters.array[fss_extended_list_write_parameter_content_e].locations, i, &ignore); diff --git a/level_3/fss_extended_list_write/c/private-common.c b/level_3/fss_extended_list_write/c/private-common.c index efead66..24de260 100644 --- a/level_3/fss_extended_list_write/c/private-common.c +++ b/level_3/fss_extended_list_write/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_extended_list_write_print_signal_received_ - void fss_extended_list_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_extended_list_write_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -23,35 +23,6 @@ extern "C" { } #endif // _di_fss_extended_list_write_print_signal_received_ -#ifndef _di_fss_extended_list_write_signal_received_ - f_status_t fss_extended_list_write_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_extended_list_write_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_extended_list_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_list_write/c/private-common.h b/level_3/fss_extended_list_write/c/private-common.h index f9ffa03..50bc4ad 100644 --- a/level_3/fss_extended_list_write/c/private-common.h +++ b/level_3/fss_extended_list_write/c/private-common.h @@ -29,31 +29,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_extended_list_write_print_signal_received_ - extern void fss_extended_list_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_extended_list_write_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_extended_list_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_extended_list_write_signal_received_ - extern f_status_t fss_extended_list_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_list_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_list_write/c/private-write.c b/level_3/fss_extended_list_write/c/private-write.c index 9e70d7c..ce58720 100644 --- a/level_3/fss_extended_list_write/c/private-write.c +++ b/level_3/fss_extended_list_write/c/private-write.c @@ -65,7 +65,7 @@ extern "C" { f_status_t fss_extended_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, const f_string_ranges_t *ignore, f_string_dynamic_t *buffer) { f_status_t status = F_none; - f_state_t state = macro_f_state_t_initialize(fss_extended_list_write_common_allocation_large_d, fss_extended_list_write_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_extended_list_write_common_allocation_large_d, fss_extended_list_write_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -169,8 +169,14 @@ extern "C" { for (;;) { - if (fss_extended_list_write_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_write_print_signal_received(main); + + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (range.start > range.stop) { @@ -376,8 +382,14 @@ extern "C" { for (; i < main->parameters.array[fss_extended_list_write_parameter_ignore_e].locations.used; ++i) { - if (fss_extended_list_write_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_write_print_signal_received(main); + + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } l = main->parameters.array[fss_extended_list_write_parameter_ignore_e].locations.array[i]; diff --git a/level_3/fss_extended_read/c/common.h b/level_3/fss_extended_read/c/common.h index 11487c0..2b78846 100644 --- a/level_3/fss_extended_read/c/common.h +++ b/level_3/fss_extended_read/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_extended_read_defines_ - #define fss_extended_read_signal_check_d 10000 + #define fss_extended_read_signal_check_d 20000 #define FSS_EXTENDED_READ_pipe_name_s "(pipe)" diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index edbaa45..8a00680 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -341,7 +341,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_read_parameter_delimit_e].values.used; ++i) { if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fss_extended_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_read_print_signal_received(main); + status = F_status_set_error(F_signal); break; @@ -542,7 +544,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fss_extended_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_read_print_signal_received(main); + status = F_status_set_error(F_signal); break; diff --git a/level_3/fss_extended_read/c/private-common.c b/level_3/fss_extended_read/c/private-common.c index 7c9f9f4..9c7dcb1 100644 --- a/level_3/fss_extended_read/c/private-common.c +++ b/level_3/fss_extended_read/c/private-common.c @@ -58,9 +58,9 @@ extern "C" { #endif // _di_fss_extended_read_depths_resize_ #ifndef _di_fss_extended_read_print_signal_received_ - void fss_extended_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_extended_read_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -68,42 +68,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_extended_read_print_signal_received_ -#ifndef _di_fss_extended_read_signal_received_ - f_status_t fss_extended_read_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_extended_read_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_extended_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index a8bbd96..ba363e0 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -257,31 +257,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_extended_read_print_signal_received_ - extern void fss_extended_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_extended_read_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_extended_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_extended_read_signal_received_ - extern f_status_t fss_extended_read_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index 74f2604..2f38ac5 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -91,7 +91,9 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fss_extended_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -177,7 +179,9 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fss_extended_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -245,7 +249,7 @@ extern "C" { #ifndef _di_fss_extended_read_load_ f_status_t fss_extended_read_load(fll_program_data_t * const main, fss_extended_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_extended_read_common_allocation_large_d, fss_extended_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; diff --git a/level_3/fss_extended_write/c/common.h b/level_3/fss_extended_write/c/common.h index fef8151..e961efb 100644 --- a/level_3/fss_extended_write/c/common.h +++ b/level_3/fss_extended_write/c/common.h @@ -69,7 +69,7 @@ extern "C" { * - content_start: A code used to represent the start of Content for use in binary formats. */ #ifndef _di_fss_extended_write_defines_ - #define fss_extended_write_signal_check_d 10000 + #define fss_extended_write_signal_check_d 20000 #define FSS_EXTENDED_WRITE_pipe_name_s "(pipe)" diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 73b27b4..4403e34 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -437,7 +437,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_write_parameter_object_e].values.used; ++i) { if (!((++main->signal_check) % fss_extended_write_signal_check_d)) { - if (fss_extended_write_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_write_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -482,7 +484,9 @@ extern "C" { for (; i < main->parameters.array[fss_extended_write_parameter_object_e].values.used; ++i) { if (!((++main->signal_check) % fss_extended_write_signal_check_d)) { - if (fss_extended_write_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_write_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_extended_write/c/private-common.c b/level_3/fss_extended_write/c/private-common.c index 8cf08ea..2d5b189 100644 --- a/level_3/fss_extended_write/c/private-common.c +++ b/level_3/fss_extended_write/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_extended_write_print_signal_received_ - void fss_extended_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_extended_write_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_extended_write_print_signal_received_ -#ifndef _di_fss_extended_write_signal_received_ - f_status_t fss_extended_write_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_extended_write_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_extended_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_write/c/private-common.h b/level_3/fss_extended_write/c/private-common.h index 2020ded..36afa06 100644 --- a/level_3/fss_extended_write/c/private-common.h +++ b/level_3/fss_extended_write/c/private-common.h @@ -29,31 +29,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_extended_write_print_signal_received_ - extern void fss_extended_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_extended_write_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_extended_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_extended_write_signal_received_ - extern f_status_t fss_extended_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_extended_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_extended_write/c/private-write.c b/level_3/fss_extended_write/c/private-write.c index 90e211b..ef2ca47 100644 --- a/level_3/fss_extended_write/c/private-write.c +++ b/level_3/fss_extended_write/c/private-write.c @@ -65,7 +65,7 @@ extern "C" { f_status_t fss_extended_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_statics_t *contents, f_string_dynamic_t *buffer) { f_status_t status = F_none; - f_state_t state = macro_f_state_t_initialize(fss_extended_write_common_allocation_large_d, fss_extended_write_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_extended_write_common_allocation_large_d, fss_extended_write_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -178,8 +178,12 @@ extern "C" { for (;;) { if (!((++main->signal_check) % fss_extended_write_signal_check_d)) { - if (fss_extended_write_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (fll_program_standard_signal_received(main)) { + fss_extended_write_print_signal_received(main); + + status = F_status_set_error(F_interrupt); + + break; } main->signal_check = 0; diff --git a/level_3/fss_identify/c/common.h b/level_3/fss_identify/c/common.h index 3c98aa2..9dc6723 100644 --- a/level_3/fss_identify/c/common.h +++ b/level_3/fss_identify/c/common.h @@ -63,7 +63,7 @@ extern "C" { * The program defines. */ #ifndef _di_fss_identify_defines_ - #define fss_identify_signal_check_d 10000 + #define fss_identify_signal_check_d 20000 #endif // _di_fss_identify_defines_ /** diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 51b225f..bb90dfb 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -288,7 +288,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_identify_signal_check_d)) { - if (fss_identify_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_identify_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_identify/c/private-common.c b/level_3/fss_identify/c/private-common.c index fc42402..3d7aba0 100644 --- a/level_3/fss_identify/c/private-common.c +++ b/level_3/fss_identify/c/private-common.c @@ -15,9 +15,9 @@ extern "C" { #endif // _di_fss_identify_data_delete_ #ifndef _di_fss_identify_print_signal_received_ - void fss_identify_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_identify_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -25,42 +25,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_identify_print_signal_received_ -#ifndef _di_fss_identify_signal_received_ - f_status_t fss_identify_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_identify_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_identify_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_identify/c/private-common.h b/level_3/fss_identify/c/private-common.h index c578f0e..1f255e5 100644 --- a/level_3/fss_identify/c/private-common.h +++ b/level_3/fss_identify/c/private-common.h @@ -57,31 +57,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_identify_print_signal_received_ - extern void fss_identify_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_identify_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_identify_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_identify_signal_received_ - extern f_status_t fss_identify_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_identify_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_identify/c/private-identify.c b/level_3/fss_identify/c/private-identify.c index 13d039b..9ed6f4b 100644 --- a/level_3/fss_identify/c/private-identify.c +++ b/level_3/fss_identify/c/private-identify.c @@ -19,7 +19,9 @@ extern "C" { do { if (!((++main->signal_check) % fss_identify_signal_check_d)) { - if (fss_identify_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_identify_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_payload_read/c/common.h b/level_3/fss_payload_read/c/common.h index b7364be..01cb855 100644 --- a/level_3/fss_payload_read/c/common.h +++ b/level_3/fss_payload_read/c/common.h @@ -63,7 +63,7 @@ extern "C" { * The program defines. */ #ifndef _di_fss_payload_read_defines_ - #define fss_payload_read_signal_check_d 10000 + #define fss_payload_read_signal_check_d 20000 #define FSS_PAYLOAD_READ_pipe_name_s "(pipe)" diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index dc35be7..826e671 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -361,7 +361,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_read_parameter_delimit_e].values.used; ++i) { if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -576,7 +578,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_payload_read/c/private-common.c b/level_3/fss_payload_read/c/private-common.c index b719102..7816a6d 100644 --- a/level_3/fss_payload_read/c/private-common.c +++ b/level_3/fss_payload_read/c/private-common.c @@ -63,9 +63,9 @@ extern "C" { #endif // _di_fss_payload_read_depths_resize_ #ifndef _di_fss_payload_read_print_signal_received_ - void fss_payload_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_payload_read_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -73,42 +73,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_payload_read_print_signal_received_ -#ifndef _di_fss_payload_read_signal_received_ - f_status_t fss_payload_read_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_payload_read_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_payload_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_payload_read/c/private-common.h b/level_3/fss_payload_read/c/private-common.h index 4d9f3b0..4900634 100644 --- a/level_3/fss_payload_read/c/private-common.h +++ b/level_3/fss_payload_read/c/private-common.h @@ -277,31 +277,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_payload_read_print_signal_received_ - extern void fss_payload_read_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_payload_read_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_payload_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_payload_read_signal_received_ - extern f_status_t fss_payload_read_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index c862b02..9406920 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -87,7 +87,9 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -173,7 +175,9 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -241,7 +245,7 @@ extern "C" { #ifndef _di_fss_payload_read_load_ f_status_t fss_payload_read_load(fll_program_data_t * const main, fss_payload_read_data_t * const data) { - f_state_t state = macro_f_state_t_initialize(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_payload_read_common_allocation_large_d, fss_payload_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t input = macro_f_string_range_t_initialize2(data->buffer.used); data->delimits_object.used = 0; @@ -449,7 +453,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -498,7 +504,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -699,7 +707,9 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -780,7 +790,9 @@ extern "C" { if (!names[at]) continue; if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -848,7 +860,9 @@ extern "C" { if (!names[i]) continue; if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } @@ -1051,7 +1065,9 @@ extern "C" { if (!names[at]) continue; if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fss_payload_read_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + return F_status_set_error(F_interrupt); } diff --git a/level_3/fss_payload_write/c/common.h b/level_3/fss_payload_write/c/common.h index 68c7551..ffb14ff 100644 --- a/level_3/fss_payload_write/c/common.h +++ b/level_3/fss_payload_write/c/common.h @@ -63,7 +63,7 @@ extern "C" { * The program defines. */ #ifndef _di_fss_payload_write_defines_ - #define fss_payload_write_signal_check_d 10000 + #define fss_payload_write_signal_check_d 20000 #define FSS_PAYLOAD_WRITE_pipe_content_end_s "\f" #define FSS_PAYLOAD_WRITE_pipe_content_ignore_s "\v" diff --git a/level_3/fss_payload_write/c/fss_payload_write.c b/level_3/fss_payload_write/c/fss_payload_write.c index 312e4ce..06f1b58 100644 --- a/level_3/fss_payload_write/c/fss_payload_write.c +++ b/level_3/fss_payload_write/c/fss_payload_write.c @@ -432,10 +432,16 @@ extern "C" { if (main->parameters.array[fss_payload_write_parameter_object_e].result == f_console_result_additional_e) { for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_object_e].values.used; ++i) { - if (fss_payload_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_payload_write_process(main, output, quote, &argv[main->parameters.array[fss_payload_write_parameter_object_e].values.array[i]], 0, &buffer); @@ -445,10 +451,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_content_e].values.used; ++i) { - if (fss_payload_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_payload_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_payload_write_parameter_content_e].values.array[i]], &buffer); @@ -459,10 +471,16 @@ extern "C" { else { for (f_array_length_t i = 0; i < main->parameters.array[fss_payload_write_parameter_object_e].values.used; ++i) { - if (fss_payload_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } status = fss_payload_write_process(main, output, quote, &argv[main->parameters.array[fss_payload_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_payload_write_parameter_content_e].values.array[i]], &buffer); diff --git a/level_3/fss_payload_write/c/private-common.c b/level_3/fss_payload_write/c/private-common.c index 5cb2006..87bff85 100644 --- a/level_3/fss_payload_write/c/private-common.c +++ b/level_3/fss_payload_write/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_payload_write_print_signal_received_ - void fss_payload_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_payload_write_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_payload_write_print_signal_received_ -#ifndef _di_fss_payload_write_signal_received_ - f_status_t fss_payload_write_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_payload_write_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_payload_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_payload_write/c/private-common.h b/level_3/fss_payload_write/c/private-common.h index b5cfa64..a3509bf 100644 --- a/level_3/fss_payload_write/c/private-common.h +++ b/level_3/fss_payload_write/c/private-common.h @@ -29,31 +29,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_payload_write_print_signal_received_ - extern void fss_payload_write_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_payload_write_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_payload_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_payload_write_signal_received_ - extern f_status_t fss_payload_write_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_payload_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c index 5494944..cab3447 100644 --- a/level_3/fss_payload_write/c/private-write.c +++ b/level_3/fss_payload_write/c/private-write.c @@ -65,7 +65,7 @@ extern "C" { f_status_t fss_payload_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t *buffer) { f_status_t status = F_none; - f_state_t state = macro_f_state_t_initialize(fss_payload_write_common_allocation_large_d, fss_payload_write_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(fss_payload_write_common_allocation_large_d, fss_payload_write_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) main, 0); f_string_range_t range = f_string_range_t_initialize; if (object) { @@ -208,10 +208,16 @@ extern "C" { for (;;) { - if (fss_payload_write_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_payload_write_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_write_print_signal_received(main); - break; + status = F_status_set_error(F_interrupt); + + break; + } + + main->signal_check = 0; } if (range.start > range.stop) { diff --git a/level_3/fss_status_code/c/common.h b/level_3/fss_status_code/c/common.h index 6e57651..d4745b0 100644 --- a/level_3/fss_status_code/c/common.h +++ b/level_3/fss_status_code/c/common.h @@ -73,7 +73,7 @@ extern "C" { * The program defines. */ #ifndef _di_fss_status_code_defines_ - #define fss_status_code_signal_check_d 10000 + #define fss_status_code_signal_check_d 20000 #endif // _di_fss_status_code_defines_ /** diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index e5007ac..b130b65 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -181,7 +181,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_status_code_signal_check_d)) { - if (fss_status_code_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_status_code_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -211,7 +213,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_status_code_signal_check_d)) { - if (fss_status_code_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_status_code_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; @@ -241,7 +245,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % fss_status_code_signal_check_d)) { - if (fss_status_code_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + fss_status_code_print_signal_received(main); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/fss_status_code/c/private-common.c b/level_3/fss_status_code/c/private-common.c index b0617ca..ed96d23 100644 --- a/level_3/fss_status_code/c/private-common.c +++ b/level_3/fss_status_code/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_fss_status_code_print_signal_received_ - void fss_status_code_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void fss_status_code_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_fss_status_code_print_signal_received_ -#ifndef _di_fss_status_code_signal_received_ - f_status_t fss_status_code_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - fss_status_code_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_fss_status_code_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fss_status_code/c/private-common.h b/level_3/fss_status_code/c/private-common.h index ecd02d2..5ba37eb 100644 --- a/level_3/fss_status_code/c/private-common.h +++ b/level_3/fss_status_code/c/private-common.h @@ -17,31 +17,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_fss_status_code_print_signal_received_ - extern void fss_status_code_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void fss_status_code_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_fss_status_code_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_fss_status_code_signal_received_ - extern f_status_t fss_status_code_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_fss_status_code_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/common.h b/level_3/iki_read/c/common.h index 8e3edb9..4c8b240 100644 --- a/level_3/iki_read/c/common.h +++ b/level_3/iki_read/c/common.h @@ -63,7 +63,7 @@ extern "C" { * The program defines. */ #ifndef _di_iki_read_defines_ - #define iki_read_signal_check_d 10000 + #define iki_read_signal_check_d 20000 enum { iki_read_mode_content_e = 1, diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 1d28165..499034b 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -433,7 +433,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % iki_read_signal_check_d)) { - if (iki_read_signal_received(&data)) { + if (fll_program_standard_signal_received(main)) { + iki_read_print_signal_received(&data); + status = F_status_set_error(F_interrupt); break; diff --git a/level_3/iki_read/c/private-common.c b/level_3/iki_read/c/private-common.c index d131d1c..3173b73 100644 --- a/level_3/iki_read/c/private-common.c +++ b/level_3/iki_read/c/private-common.c @@ -15,9 +15,9 @@ extern "C" { #endif // _di_iki_read_data_delete_ #ifndef _di_iki_read_print_signal_received_ - void iki_read_print_signal_received(iki_read_data_t * const data, const f_status_t signal) { + void iki_read_print_signal_received(iki_read_data_t * const data) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); @@ -25,42 +25,13 @@ extern "C" { flockfile(data->main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); - fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, data->main->signal_received, data->main->context.set.notable); fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); funlockfile(data->main->warning.to.stream); } #endif // _di_iki_read_print_signal_received_ -#ifndef _di_iki_read_signal_received_ - f_status_t iki_read_signal_received(iki_read_data_t * const data) { - - if (data->main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(data->main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - iki_read_print_signal_received(data, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_iki_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/private-common.h b/level_3/iki_read/c/private-common.h index 8833f29..7c5536f 100644 --- a/level_3/iki_read/c/private-common.h +++ b/level_3/iki_read/c/private-common.h @@ -76,31 +76,11 @@ extern "C" { * * @param data * The program data. - * @param signal - * The signal received. */ #ifndef _di_iki_read_print_signal_received_ - extern void iki_read_print_signal_received(iki_read_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; + extern void iki_read_print_signal_received(iki_read_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_iki_read_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param data - * The program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_iki_read_signal_received_ - extern f_status_t iki_read_signal_received(iki_read_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_iki_read_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index 4bc080c..d41ba58 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -104,7 +104,7 @@ extern "C" { bool unmatched = F_true; { - f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data->main, 0); status = fl_iki_read(state, &data->buffer, buffer_range, iki_data); } @@ -265,7 +265,7 @@ extern "C" { f_string_range_t range = buffer_range; { - f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data->main, 0); status = fl_iki_read(state, &data->buffer, &range, iki_data); } @@ -472,7 +472,7 @@ extern "C" { } { - f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, 0, 0, 0, 0); + f_state_t state = macro_f_state_t_initialize(iki_read_common_allocation_large_d, iki_read_common_allocation_small_d, 0, &fll_program_standard_signal_state, 0, (void *) data->main, 0); status = fl_iki_read(state, &data->buffer, &range, iki_data); } @@ -501,7 +501,9 @@ extern "C" { for (; i < data->main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { if (!((++data->main->signal_check) % iki_read_signal_check_d)) { - if (iki_read_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { + iki_read_print_signal_received(data); + f_string_dynamic_resize(0, &name); return F_status_set_error(F_interrupt); diff --git a/level_3/iki_write/c/common.h b/level_3/iki_write/c/common.h index eff9b94..a7dbc8d 100644 --- a/level_3/iki_write/c/common.h +++ b/level_3/iki_write/c/common.h @@ -63,7 +63,7 @@ extern "C" { * The program defines. */ #ifndef _di_iki_write_defines_ - #define iki_write_signal_check_d 10000 + #define iki_write_signal_check_d 20000 #endif // _di_iki_write_defines_ /** diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index d5fbd40..b33fd27 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -293,7 +293,7 @@ extern "C" { for (f_status_t status_pipe = F_none; ; ) { if (!((++main->signal_check) % iki_write_signal_check_d)) { - if (iki_write_signal_received(&data)) { + if (fll_program_standard_signal_received(main)) { status = F_status_set_error(F_interrupt); break; @@ -420,7 +420,7 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[iki_write_parameter_object_e].values.used; ++i) { if (!((++main->signal_check) % iki_write_signal_check_d)) { - if (iki_write_signal_received(&data)) { + if (fll_program_standard_signal_received(main)) { status = F_status_set_error(F_interrupt); break; diff --git a/level_3/iki_write/c/private-common.c b/level_3/iki_write/c/private-common.c index c169f47..5168e72 100644 --- a/level_3/iki_write/c/private-common.c +++ b/level_3/iki_write/c/private-common.c @@ -13,9 +13,9 @@ extern "C" { #endif // _di_iki_write_data_delete_ #ifndef _di_iki_write_print_signal_received_ - void iki_write_print_signal_received(iki_write_data_t * const data, const f_status_t signal) { + void iki_write_print_signal_received(iki_write_data_t * const data) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); @@ -23,42 +23,13 @@ extern "C" { flockfile(data->main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", data->main->warning.to.stream, data->main->context.set.reset, f_string_eol_s, f_string_eol_s, data->main->context.set.warning, data->main->context.set.warning); - fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, signal, data->main->context.set.notable); + fl_print_format("%[%i%]", data->main->warning.to.stream, data->main->context.set.notable, data->main->signal, data->main->context.set.notable); fl_print_format("%[.%]%r", data->main->warning.to.stream, data->main->context.set.warning, data->main->context.set.warning, f_string_eol_s); funlockfile(data->main->warning.to.stream); } #endif // _di_iki_write_print_signal_received_ -#ifndef _di_iki_write_signal_received_ - f_status_t iki_write_signal_received(iki_write_data_t * const data) { - - if (data->main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(data->main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - iki_write_print_signal_received(data, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_iki_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/iki_write/c/private-common.h b/level_3/iki_write/c/private-common.h index 27f1afe..6dbad4c 100644 --- a/level_3/iki_write/c/private-common.h +++ b/level_3/iki_write/c/private-common.h @@ -65,31 +65,11 @@ extern "C" { * * @param data * The program data. - * @param signal - * The signal received. */ #ifndef _di_iki_write_print_signal_received_ - extern void iki_write_print_signal_received(iki_write_data_t * const data, const f_status_t signal) F_attribute_visibility_internal_d; + extern void iki_write_print_signal_received(iki_write_data_t * const data) F_attribute_visibility_internal_d; #endif // _di_iki_write_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param data - * The program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_iki_write_signal_received_ - extern f_status_t iki_write_signal_received(iki_write_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_iki_write_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/status_code/c/common.h b/level_3/status_code/c/common.h index 0baba81..d2fed6e 100644 --- a/level_3/status_code/c/common.h +++ b/level_3/status_code/c/common.h @@ -73,7 +73,7 @@ extern "C" { * The program defines. */ #ifndef _di_status_code_defines_ - #define status_code_signal_check_d 10000 + #define status_code_signal_check_d 20000 #endif // _di_status_code_defines_ /** diff --git a/level_3/status_code/c/private-common.c b/level_3/status_code/c/private-common.c index 6ce8b7a..1ee3c476 100644 --- a/level_3/status_code/c/private-common.c +++ b/level_3/status_code/c/private-common.c @@ -6,9 +6,9 @@ extern "C" { #endif #ifndef _di_status_code_print_signal_received_ - void status_code_print_signal_received(fll_program_data_t * const main, const f_status_t signal) { + void status_code_print_signal_received(fll_program_data_t * const main) { - if (main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (main->warning.verbosity != f_console_verbosity_verbose_e && main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(main->warning.to.stream); @@ -16,42 +16,13 @@ extern "C" { flockfile(main->warning.to.stream); fl_print_format("%]%r%r%[Received signal code %]", main->warning.to.stream, main->context.set.reset, f_string_eol_s, f_string_eol_s, main->context.set.warning, main->context.set.warning); - fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, signal, main->context.set.notable); + fl_print_format("%[%i%]", main->warning.to.stream, main->context.set.notable, main->signal_received, main->context.set.notable); fl_print_format("%[.%]%r", main->warning.to.stream, main->context.set.warning, main->context.set.warning, f_string_eol_s); funlockfile(main->warning.to.stream); } #endif // _di_status_code_print_signal_received_ -#ifndef _di_status_code_signal_received_ - f_status_t status_code_signal_received(fll_program_data_t * const main) { - - if (main->signal.id == -1) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - status_code_print_signal_received(main, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_status_code_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/status_code/c/private-common.h b/level_3/status_code/c/private-common.h index 4b58f32..fb5c7a7 100644 --- a/level_3/status_code/c/private-common.h +++ b/level_3/status_code/c/private-common.h @@ -17,31 +17,11 @@ extern "C" { * * @param main * The main program data. - * @param signal - * The signal received. */ #ifndef _di_status_code_print_signal_received_ - extern void status_code_print_signal_received(fll_program_data_t * const main, const f_status_t signal) F_attribute_visibility_internal_d; + extern void status_code_print_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; #endif // _di_status_code_print_signal_received_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param main - * The main program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_status_code_signal_received_ - extern f_status_t status_code_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d; -#endif // _di_status_code_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 1caf71d..3c383e8 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -181,7 +181,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % status_code_signal_check_d)) { - if (status_code_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + status_code_print_signal_received(main); + status = F_status_set_error(F_signal); break; @@ -211,7 +213,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % status_code_signal_check_d)) { - if (status_code_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + status_code_print_signal_received(main); + status = F_status_set_error(F_signal); break; @@ -241,7 +245,9 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % status_code_signal_check_d)) { - if (status_code_signal_received(main)) { + if (fll_program_standard_signal_received(main)) { + status_code_print_signal_received(main); + status = F_status_set_error(F_signal); break; diff --git a/level_3/utf8/c/common.h b/level_3/utf8/c/common.h index 092b240..c71d95e 100644 --- a/level_3/utf8/c/common.h +++ b/level_3/utf8/c/common.h @@ -80,7 +80,7 @@ extern "C" { * The program defines. */ #ifndef _di_utf8_defines_ - #define utf8_signal_check_d 10000 + #define utf8_signal_check_d 20000 #define UTF8_string_combining_is_s "C" #define UTF8_string_combining_not_s "N" diff --git a/level_3/utf8/c/private-common.c b/level_3/utf8/c/private-common.c index 6a7b232..e8bbe72 100644 --- a/level_3/utf8/c/private-common.c +++ b/level_3/utf8/c/private-common.c @@ -18,35 +18,6 @@ extern "C" { } #endif // _di_utf8_data_delete_ -#ifndef _di_utf8_signal_received_ - f_status_t utf8_signal_received(utf8_data_t * const data) { - - if (!data->main->signal.id) { - return F_false; - } - - struct signalfd_siginfo information; - - memset(&information, 0, sizeof(struct signalfd_siginfo)); - - if (f_signal_read(data->main->signal, 0, &information) == F_signal) { - switch (information.ssi_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: - utf8_print_signal_received(data, information.ssi_signo); - - return information.ssi_signo; - } - } - - return F_false; - } -#endif // _di_utf8_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/utf8/c/private-common.h b/level_3/utf8/c/private-common.h index 5cff7cf..a291ee2 100644 --- a/level_3/utf8/c/private-common.h +++ b/level_3/utf8/c/private-common.h @@ -94,24 +94,6 @@ extern "C" { extern void utf8_data_delete(utf8_data_t *data) F_attribute_visibility_internal_d; #endif // _di_utf8_data_delete_ -/** - * Check to see if a process signal is received. - * - * Only signals that are blocked via main.signal will be received. - * - * @param data - * The program data. - * - * @return - * A positive number representing a valid signal on signal received. - * F_false on no signal received. - * - * @see f_signal_read() - */ -#ifndef _di_utf8_signal_received_ - extern f_status_t utf8_signal_received(utf8_data_t * const data) F_attribute_visibility_internal_d; -#endif // _di_utf8_signal_received_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/utf8/c/private-print.c b/level_3/utf8/c/private-print.c index 3b88459..780f9b2 100644 --- a/level_3/utf8/c/private-print.c +++ b/level_3/utf8/c/private-print.c @@ -255,7 +255,7 @@ extern "C" { #ifndef _di_utf8_print_signal_received_ void utf8_print_signal_received(utf8_data_t * const data, const f_status_t signal) { - if (data->main->warning.verbosity != f_console_verbosity_verbose_e) return; + if (data->main->warning.verbosity != f_console_verbosity_verbose_e && data->main->warning.verbosity != f_console_verbosity_debug_e) return; // Must flush and reset color because the interrupt may have interrupted the middle of a print function. fflush(data->main->warning.to.stream); diff --git a/level_3/utf8/c/private-utf8.c b/level_3/utf8/c/private-utf8.c index f616bc9..255a46e 100644 --- a/level_3/utf8/c/private-utf8.c +++ b/level_3/utf8/c/private-utf8.c @@ -27,10 +27,10 @@ extern "C" { for (; text.string[0] && F_status_is_error_not(status); ) { if (!((++data->main->signal_check) % utf8_signal_check_d)) { - if (utf8_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { utf8_print_signal_received(data, status); - status = F_status_set_error(F_signal); + status = F_status_set_error(F_interrupt); break; } diff --git a/level_3/utf8/c/private-utf8.h b/level_3/utf8/c/private-utf8.h index 53de6b9..6670bda 100644 --- a/level_3/utf8/c/private-utf8.h +++ b/level_3/utf8/c/private-utf8.h @@ -24,7 +24,7 @@ extern "C" { * @return * F_true on success and is valid. * F_false on success and contains invalid sequences. - * F_signal on (exit) signal received. + * F_interrupt on (exit) signal received. * * Errors (with error bit) from: utf8_convert_binary() * Errors (with error bit) from: utf8_convert_codepoint() diff --git a/level_3/utf8/c/private-utf8_binary.c b/level_3/utf8/c/private-utf8_binary.c index 5c1d94d..b5f440b 100644 --- a/level_3/utf8/c/private-utf8_binary.c +++ b/level_3/utf8/c/private-utf8_binary.c @@ -83,10 +83,10 @@ extern "C" { for (i = 0; F_status_is_fine(status) && i < data->buffer.used; ) { if (!((++data->main->signal_check) % utf8_signal_check_d)) { - if (utf8_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { utf8_print_signal_received(data, status); - status = F_signal; + status = F_interrupt; break; } @@ -130,10 +130,10 @@ extern "C" { i = 0; data->buffer.used = 0; - } while (F_status_is_fine(status) && status != F_signal); + } while (F_status_is_fine(status) && status != F_interrupt); // Handle last (incomplete) character when the buffer ended before the character is supposed to end. - if (F_status_is_error_not(status) && status != F_signal && next == F_false) { + if (F_status_is_error_not(status) && status != F_interrupt && next == F_false) { character.used = j; if (data->mode & utf8_mode_from_binary_d) { @@ -154,7 +154,7 @@ extern "C" { data->buffer.used = 0; - if (F_status_is_error(status) || status == F_signal) { + if (F_status_is_error(status) || status == F_interrupt) { return status; } diff --git a/level_3/utf8/c/private-utf8_binary.h b/level_3/utf8/c/private-utf8_binary.h index 732a408..43ee503 100644 --- a/level_3/utf8/c/private-utf8_binary.h +++ b/level_3/utf8/c/private-utf8_binary.h @@ -47,14 +47,14 @@ extern "C" { * @return * F_true on success and is valid. * F_false on success and contains invalid sequences. - * F_signal on (exit) signal received. + * F_interrupt on (exit) signal received. * * Errors (with error bit) from: utf8_convert_binary() * Errors (with error bit) from: utf8_detect_codepoint() * + * @see fll_program_standard_signal_received() * @see utf8_convert_binary() * @see utf8_detect_codepoint() - * @see utf8_signal_received() */ #ifndef _di_utf8_process_file_binary_ extern f_status_t utf8_process_file_binary(utf8_data_t * const data, const f_file_t file) F_attribute_visibility_internal_d; diff --git a/level_3/utf8/c/private-utf8_codepoint.c b/level_3/utf8/c/private-utf8_codepoint.c index 64f5201..6df7b29 100644 --- a/level_3/utf8/c/private-utf8_codepoint.c +++ b/level_3/utf8/c/private-utf8_codepoint.c @@ -219,10 +219,10 @@ extern "C" { for (i = 0; F_status_is_fine(status) && i < data->buffer.used; ) { if (!((++data->main->signal_check) % utf8_signal_check_d)) { - if (utf8_signal_received(data)) { + if (fll_program_standard_signal_received(data->main)) { utf8_print_signal_received(data, status); - status = F_signal; + status = F_interrupt; break; } @@ -266,10 +266,10 @@ extern "C" { i = 0; data->buffer.used = 0; - } while (F_status_is_fine(status) && status != F_signal); + } while (F_status_is_fine(status) && status != F_interrupt); // Handle last (incomplete) character when the buffer ended before the character is supposed to end. - if (F_status_is_error_not(status) && status != F_signal && next == F_false) { + if (F_status_is_error_not(status) && status != F_interrupt && next == F_false) { character.used = j; if (data->mode & utf8_mode_from_binary_d) { @@ -290,7 +290,7 @@ extern "C" { data->buffer.used = 0; - if (F_status_is_error(status) || status == F_signal) { + if (F_status_is_error(status) || status == F_interrupt) { return status; } diff --git a/level_3/utf8/c/private-utf8_codepoint.h b/level_3/utf8/c/private-utf8_codepoint.h index 2b1a4f2..fcd935c 100644 --- a/level_3/utf8/c/private-utf8_codepoint.h +++ b/level_3/utf8/c/private-utf8_codepoint.h @@ -68,14 +68,14 @@ extern "C" { * @return * F_true on success and is valid. * F_false on success and contains invalid sequences. - * F_signal on (exit) signal received. + * F_interrupt on (exit) signal received. * * Errors (with error bit) from: utf8_convert_binary() * Errors (with error bit) from: utf8_detect_codepoint() * + * @see fll_program_standard_signal_received() * @see utf8_convert_binary() * @see utf8_detect_codepoint() - * @see utf8_signal_received() */ #ifndef _di_utf8_process_file_codepoint_ extern f_status_t utf8_process_file_codepoint(utf8_data_t * const data, const f_file_t file) F_attribute_visibility_internal_d; diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index 5e7d92c..1730488 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -390,17 +390,17 @@ extern "C" { } } - if (F_status_is_error_not(status) && status != F_signal && main->parameters.array[utf8_parameter_from_file_e].result == f_console_result_additional_e) { + if (F_status_is_error_not(status) && status != F_interrupt && main->parameters.array[utf8_parameter_from_file_e].result == f_console_result_additional_e) { f_array_length_t i = 0; f_array_length_t index = 0; f_file_t file = macro_f_file_t_initialize(0, -1, F_file_flag_read_only_d, 32768, F_file_default_write_size_d); - for (; i < main->parameters.array[utf8_parameter_from_file_e].values.used && status != F_signal; ++i) { + for (; i < main->parameters.array[utf8_parameter_from_file_e].values.used && status != F_interrupt; ++i) { if (!((++main->signal_check) % utf8_signal_check_d)) { - if (utf8_signal_received(&data)) { - status = F_status_set_error(F_signal); + if (fll_program_standard_signal_received(main)) { + status = F_status_set_error(F_interrupt); break; } @@ -443,12 +443,12 @@ extern "C" { } // for } - if (F_status_is_error_not(status) && status != F_signal && main->parameters.remaining.used) { + if (F_status_is_error_not(status) && status != F_interrupt && main->parameters.remaining.used) { for (f_array_length_t i = 0; F_status_is_error_not(status) && i < main->parameters.remaining.used; ++i) { if (!((++main->signal_check) % utf8_signal_check_d)) { - if (utf8_signal_received(&data)) { - status = F_status_set_error(F_signal); + if (fll_program_standard_signal_received(main)) { + status = F_status_set_error(F_interrupt); break; } @@ -470,7 +470,7 @@ extern "C" { } if (main->output.verbosity != f_console_verbosity_quiet_e && main->parameters.array[utf8_parameter_verify_e].result == f_console_result_none_e) { - if (status == F_signal) { + if (status == F_interrupt) { fflush(data.file.stream); if (data.file.stream != main->output.to.stream) { @@ -483,7 +483,7 @@ extern "C" { utf8_data_delete(&data); - if (F_status_is_error(status) || status == F_signal) { + if (F_status_is_error(status) || status == F_interrupt) { return status; } diff --git a/level_3/utf8/c/utf8.h b/level_3/utf8/c/utf8.h index c8fa417..1d65bac 100644 --- a/level_3/utf8/c/utf8.h +++ b/level_3/utf8/c/utf8.h @@ -96,7 +96,7 @@ extern "C" { * F_none on success. * F_true on success when performing verification and verify passed. * F_false on success when performing verification and verify failed. - * F_signal on (exit) signal received. + * F_interrupt on (exit) signal received. * * Status codes (with error bit) are returned on any problem. */ -- 1.8.3.1