#include <program/controller/main/print/error/entry/action.h>
#include <program/controller/main/print/error/entry/item.h>
#include <program/controller/main/print/error/entry/setting.h>
+#include <program/controller/main/print/error/lock.h>
#include <program/controller/main/print/error/perform/pid.h>
#include <program/controller/main/print/error/rule.h>
#include <program/controller/main/print/error/rule/action.h>
}
if (F_status_is_error_not(status) && cache->object_items.used) {
- status = f_memory_array_increase_by(cache->object_items.used, &entry->items.array, &entry->items.used, &entry->items.size);
+ status = f_memory_array_increase_by(cache->object_items.used, sizeof(f_range_t), (void **) &cache->object_items.array, &cache->object_items.used, &cache->object_items.size);
if (F_status_is_error(status)) {
controller_print_error_entry(&main->program.error, cache, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase_by), F_true);
cache->action.name_action.used = 0;
cache->action.name_item.used = 0;
- status = controller_entry_items_increase_by(controller_allocation_small_d, &entry->items);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_entry_item_t), (void **) &entry->items.array, &entry->items.used, &entry->items.size);
if (F_status_is_error(status)) {
- controller_print_error_entry(&main->program.error, cache, is_entry, F_status_set_fine(status), macro_controller_f(controller_entry_items_increase_by), F_true);
+ controller_print_error_entry(&main->program.error, cache, is_entry, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true);
break;
}
fl_print_format(f_string_format_Q_single_s.string, main->program.warning.to, main->program.warning.notable, cache->action.name_file, main->program.warning.notable);
fl_print_format(f_string_format_sentence_end_quote_s.string, main->program.warning.to, main->program.warning.context, main->program.warning.context, f_string_eol_s);
- controller_print_error_entry_cache(is_entry, &main->program.warning, &cache->action);
+ controller_print_error_entry_cache(&main->program.warning, &cache->action, is_entry);
controller_unlock_print_flush(main->program.warning.to, &main->thread);
}
}
}
- // Only make the rule and control threads available once any/all pre-processing are complete.
+ // Only make the rule and control threads available once any/all pre-processing is complete.
if (F_status_is_error_not(status) && status != F_failure && status != F_child && main->thread.enabled == controller_thread_enabled_e) {
if (!(main->setting.flag & controller_main_flag_validate_e)) {
controller_thread_delete(&main->thread);
if (F_status_set_fine(status) == F_interrupt) {
- fll_program_print_signal_received(&main->program.warning, main->thread.signal);
+ main->setting.state.status = F_status_set_error(F_interrupt);
- if (main->program.output.verbosity > f_console_verbosity_quiet_e) {
- fll_print_dynamic_raw(f_string_eol_s, main->program.output.to);
+ if (main->thread.signal) {
+ main->program.signal_received = main->thread.signal;
}
- fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
+ if (main->program.message.verbosity > f_console_verbosity_error_e) {
+ fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
+ }
- main->setting.state.status = F_status_set_error(F_interrupt);
+ fll_program_print_signal_received(&main->program.warning, main->program.signal_received);
}
else {
main->setting.state.status = F_status_is_error(status) ? F_status_set_error(F_failure) : F_okay;
for (i = 0; i < cache->object_actions.used; ++i) {
- status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &actions->array, &actions->used, &actions->size);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &actions->array, &actions->used, &actions->size);
if (F_status_is_error(status)) {
- controller_print_error(&main->program.error, macro_controller_f(f_memory_array_increase_by));
+ controller_print_error(&main->program.error, macro_controller_f(f_memory_array_increase));
return status;
}
method = controller_rule_action_method_extended_e;
}
- status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(controller_rule_action_t), (void **) &item->actions.array, &item->actions.used, &item->actions.size);
if (F_status_is_error(status)) {
controller_print_error_status(&main->program.error, macro_controller_f(f_memory_array_increase_by), F_status_set_fine(status));
continue;
}
- status = f_memory_array_increase_by(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size);
+ status = f_memory_array_increase(controller_allocation_small_d, sizeof(f_string_dynamic_t), (void **) &setting_values->array, &setting_values->used, &setting_values->size);
if (F_status_is_error(status)) {
- controller_print_error_rule(&main->program.error, cache->action, F_status_set_fine(status), "f_memory_array_increase_by", F_true, F_false);
+ controller_print_error_rule(&main->program.error, cache->action, F_status_set_fine(status), macro_controller_f(f_memory_array_increase), F_true, F_false);
}
}
f_number_unsigned_t j = 0;
pid_t pid = 0;
- // A simple but inaccurate interval counter (expect this to be replaced in the future).
+ // A simple but inaccurate interval counter.
const f_number_unsigned_t interval_nanoseconds = entry->timeout_exit < 1000 ? (entry->timeout_exit < 100 ? 5000000 : 100000000) : 500000000;
const f_number_unsigned_t interval_milliseconds = entry->timeout_exit < 1000 ? (entry->timeout_exit < 100 ? 5 : 100) : 500;
time.tv_sec = 0;
time.tv_nsec = interval_nanoseconds;
- if (main->process.mode == controller_process_mode_helper_e && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
- int value = 0;
- f_number_unsigned_t lapsed = 0;
-
+ if (main->process.mode == controller_process_mode_helper_e && !(main->setting.flag & controller_main_flag_validate_e)) {
for (i = 0; i < main->thread.instances.used; ++i) {
if (!main->thread.instances.array[i]) continue;
main->thread.id_signal = 0;
}
- if (main->process.mode == controller_process_mode_helper_e && main->program.parameters.array[controller_parameter_validate_e].result == f_console_result_none_e) {
+ if (main->process.mode == controller_process_mode_helper_e && !(main->setting.flag & controller_main_flag_validate_e)) {
f_thread_mutex_unlock(&main->thread.lock.cancel);
return;
while (instance->childs.array[j] > 0 && lapsed < entry->timeout_exit) {
- // A hackish way to determine if the child instance exists while waiting.
+ // A hackish way to determine if the child instance exists while waiting (@todo look into pidfd() and epoll_wait()).
if (getpgid(instance->childs.array[j]) >= 0) {
time.tv_sec = 0;
time.tv_nsec = interval_nanoseconds;
if (pid) {
while (lapsed < entry->timeout_exit) {
- // A hackish way to determine if the instance exists while waiting.
+ // A hackish way to determine if the instance exists while waiting (@todo look into pidfd() and epoll_wait()).
if (getpgid(pid) >= 0) {
time.tv_sec = 0;
time.tv_nsec = interval_nanoseconds;
if (instance->childs.array[j]) {
- // A hackish way to determine if the child instance exists, and if it does then forcibly terminate it.
+ // A hackish way to determine if the child instance exists, and if it does then forcibly terminate it (@todo look into pidfd() and epoll_wait()).
if (getpgid(instance->childs.array[j]) >= 0) {
f_signal_send(F_signal_kill, instance->childs.array[j]);
}
#ifndef _di_controller_thread_instance_exit_
void controller_thread_instance_exit(controller_t * const main) {
- if (!main) return;
-
- if (main->thread.enabled != controller_thread_enabled_exit_e) return;
+ if (!main || main->thread.enabled != controller_thread_enabled_exit_e) return;
if (main->process.ready == controller_process_ready_done_e) {