// According to the manpages, pthread_exit() calls exit(0), which is not good because a non-zero exit code may be returned.
if (main->child) exit(main->child);
-
- return 0;
}
-
- f_thread_condition_signal_all(&entry->global->thread->lock.alert_condition);
+ else {
+ f_thread_condition_signal_all(&entry->global->thread->lock.alert_condition);
+ }
return 0;
}
controller_thread_delete_simple(entry->global->thread);
controller_setting_delete_simple(entry->global->setting);
controller_main_delete(entry->global->main);
-
- return 0;
}
+ else {
+ controller_thread_process_exit_force_set_disable(entry->global);
- controller_thread_process_exit_force_set_disable(entry->global);
-
- f_thread_condition_signal_all(&entry->global->thread->lock.alert_condition);
+ f_thread_condition_signal_all(&entry->global->thread->lock.alert_condition);
+ }
return 0;
}
#ifndef _di_controller_thread_process_
void controller_thread_process(const bool is_normal, controller_process_t * const process) {
- {
- controller_thread_t *thread = (controller_thread_t *) process->main_thread;
-
- if (!controller_thread_is_enabled(is_normal, thread)) return;
- }
+ if (!controller_thread_is_enabled(is_normal, (controller_thread_t *) process->main_thread)) return;
const f_status_t status = controller_rule_process_do(controller_process_option_asynchronous_d, process);
// A forked child process should deallocate memory on exit.
// It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below.
// Deallocate as much as possible.
- controller_main_t *main = (controller_main_t *) process->main_data;
- controller_setting_t *setting = (controller_setting_t *) process->main_setting;
- controller_thread_t *thread = (controller_thread_t *) process->main_thread;
+ controller_main_t * const main = (controller_main_t *) process->main_data;
- controller_thread_delete_simple(thread);
- controller_setting_delete_simple(setting);
+ controller_thread_delete_simple((controller_thread_t *) process->main_thread);
+ controller_setting_delete_simple((controller_setting_t *) process->main_setting);
controller_main_delete(main);
// According to the manpages, pthread_exit() calls exit(0), which is not good because a non-zero exit code may be returned.
struct timespec time;
- controller_entry_t *entry = 0;
+ controller_entry_t * const entry = is_normal ? &global->setting->entry : &global->setting->exit;
controller_process_t *process = 0;
f_array_length_t i = 0;
f_array_length_t j = 0;
pid_t pid = 0;
- if (is_normal) {
- entry = &global->setting->entry;
- }
- else {
- entry = &global->setting->exit;
- }
-
// A simple but inaccurate interval counter (expect this to be replaced in the future).
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;
process = global->thread->processs.array[i];
// Do not wait for processes, when not performing "execute" during exit.
- if (process->type == controller_process_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) {
- continue;
- }
+ if (process->type == controller_process_type_exit_e && global->thread->enabled != controller_thread_enabled_exit_execute_e) continue;
for (j = 0; j < process->childs.used && lapsed < entry->timeout_exit; ++j) {
#ifndef _di_controller_thread_process_exit_
void controller_thread_process_exit(controller_global_t * const global) {
- if (global->thread->enabled != controller_thread_enabled_exit_e) {
- return;
- }
+ if (global->thread->enabled != controller_thread_enabled_exit_e) return;
if (global->setting->ready == controller_setting_ready_done_e) {