f_status_t controller_rule_execute_foreground(const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, controller_execute_set_t * const execute_set, controller_process_t * const process) {
f_status_t status = F_none;
- f_status_t status_lock = F_none;
controller_main_t * const main = (controller_main_t *) process->main_data;
controller_thread_t * const thread = (controller_thread_t *) process->main_thread;
return status;
}
- pid_t *child = 0;
+ pid_t *process_child_id = 0;
{
f_array_length_t i = 0;
++i;
} // while
- child = &process->childs.array[i];
+ process_child_id = &process->childs.array[i];
if (i == process->childs.used) {
++process->childs.used;
f_thread_unlock(&process->lock);
- status_lock = controller_lock_write_process(process, thread, &process->lock);
+ f_status_t status_lock = controller_lock_write_process(process, thread, &process->lock);
if (F_status_is_error(status_lock)) {
controller_lock_print_error_critical(main->error, F_status_set_fine(status_lock), F_false, thread);
}
// Assign the child process id to allow for the cancel process to send appropriate termination signals to the child process.
- *child = id_child;
+ *process_child_id = id_child;
f_thread_unlock(&process->lock);
controller_lock_print_error_critical(main->error, F_status_set_fine(status_lock), F_true, thread);
}
+ // Have the parent wait for the child process to finish.
if (F_status_set_fine(status_lock) != F_interrupt) {
-
- // Have the parent wait for the child process to finish.
waitpid(id_child, &result.status, 0);
}
if (F_status_set_fine(status_lock) == F_interrupt || !controller_thread_is_enabled_process(process, thread)) {
- if (status_lock == F_none) {
- return F_status_set_error(F_interrupt);
- }
-
- return F_status_set_error(F_lock);
+ return status_lock == F_none ? F_status_set_error(F_interrupt) : F_status_set_error(F_lock);
}
if (status_lock == F_none) {
if (F_status_set_fine(status_lock) != F_interrupt) {
status = controller_lock_read_process(process, thread, &process->lock);
-
- if (status == F_none) {
- return status_lock;
- }
+ if (status == F_none) return status_lock;
}
return F_status_set_error(F_lock);
process->result = result.status;
// Remove the pid now that waidpid() has returned.
- *child = 0;
+ *process_child_id = 0;
f_thread_unlock(&process->lock);
}
}
- if (status == F_child || F_status_set_fine(status) == F_interrupt) {
- return status;
- }
+ if (status == F_child || F_status_set_fine(status) == F_interrupt) return status;
if (F_status_is_error(status)) {
status = F_status_set_fine(status);
f_status_t controller_rule_execute_pid_with(const f_string_dynamic_t pid_file, const uint8_t type, const f_string_static_t program, const f_string_statics_t arguments, const uint8_t options, const uint8_t with, controller_execute_set_t * const execute_set, controller_process_t * const process) {
f_status_t status = F_none;
- f_status_t status_lock = F_none;
controller_main_t * const main = (controller_main_t *) process->main_data;
controller_thread_t * const thread = (controller_thread_t *) process->main_thread;
return status;
}
- pid_t *child = 0;
- f_string_dynamic_t *child_pid_file = 0;
+ pid_t *process_child_id = 0;
+ f_string_dynamic_t *process_child_pid_file = 0;
{
f_array_length_t i = 0;
++i;
} // while
- child = &process->childs.array[i];
+ process_child_id = &process->childs.array[i];
if (i == process->childs.used) {
++process->childs.used;
++i;
} // while
- child_pid_file = &process->path_pids.array[i];
+ process_child_pid_file = &process->path_pids.array[i];
if (i == process->path_pids.used) {
++process->path_pids.used;
return F_status_set_error(F_file_found);
}
- status = f_string_dynamic_append_nulless(pid_file, child_pid_file);
+ status = f_string_dynamic_append_nulless(pid_file, process_child_pid_file);
if (F_status_is_error(status)) {
controller_print_error(thread, main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true);
f_thread_unlock(&process->lock);
- status_lock = controller_lock_write_process(process, thread, &process->lock);
+ f_status_t status_lock = controller_lock_write_process(process, thread, &process->lock);
if (F_status_is_error(status_lock)) {
controller_lock_print_error_critical(main->error, F_status_set_fine(status_lock), F_false, thread);
}
// Assign the child process id to allow for the cancel process to send appropriate termination signals to the child process.
- *child = id_child;
+ *process_child_id = id_child;
f_thread_unlock(&process->lock);
controller_lock_print_error_critical(main->error, F_status_set_fine(status_lock), F_true, thread);
}
+ // The child process should perform the change into background, therefore it is safe to wait for the child to exit (another process is spawned).
if (F_status_set_fine(status_lock) != F_interrupt) {
-
- // The child process should perform the change into background, therefore it is safe to wait for the child to exit (another process is spawned).
waitpid(id_child, &result.status, 0);
}
if (!controller_thread_is_enabled_process(process, thread)) {
- if (status_lock == F_none) {
- return F_status_set_error(F_interrupt);
- }
-
- return F_status_set_error(F_lock);
+ return status_lock == F_none ? F_status_set_error(F_interrupt) : F_status_set_error(F_lock);
}
if (status_lock == F_none) {
if (F_status_set_fine(status_lock) != F_interrupt) {
status = controller_lock_read_process(process, thread, &process->lock);
-
- if (status == F_none) {
- return status_lock;
- }
+ if (status == F_none) return status_lock;
}
return F_status_set_error(F_lock);
process->result = result.status;
// Remove the pid now that waidpid() has returned.
- *child = 0;
+ *process_child_id = 0;
f_thread_unlock(&process->lock);
}
}
- if (status == F_child || F_status_set_fine(status) == F_interrupt) {
- return status;
- }
+ if (status == F_child || F_status_set_fine(status) == F_interrupt) return status;
if (F_status_is_error(status)) {
status = F_status_set_fine(status);