From e165d105730839e8e6fc83aa1820fdccc476d759 Mon Sep 17 00:00:00 2001 From: shixuantong Date: Tue, 8 Apr 2025 19:19:29 +0800 Subject: [PATCH] set all task status to FAILED if exit code not is 0 --- src/services/syssentry/syssentry.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/services/syssentry/syssentry.py b/src/services/syssentry/syssentry.py index def3ed7..4c46076 100644 --- a/src/services/syssentry/syssentry.py +++ b/src/services/syssentry/syssentry.py @@ -560,25 +560,22 @@ def sigchld_handler(signum, _f): """ while True: try: - child_pid, child_exit_code = os.waitpid(-1, os.WNOHANG) + child_pid, child_exit_status = os.waitpid(-1, os.WNOHANG) logging.debug("sigchld pid :%d", child_pid) task = get_task_by_pid(child_pid) if not task: logging.debug("pid %d cannot find task, ignore", child_pid) break logging.debug("task name %s", task.name) - if os.WIFEXITED(child_exit_code): - # exit normally with exit() syscall + if os.waitstatus_to_exitcode(child_exit_status) == 0: + # exit normally with exit(0) or return 0 if task.type == "PERIOD" and task.period_enabled: set_runtime_status(task.name, "WAITING") else: set_runtime_status(task.name, "EXITED") else: - # exit abnormally - if not task.period_enabled: - set_runtime_status(task.name, "EXITED") - else: - set_runtime_status(task.name, "FAILED") + # exit abnormally exit(!0) or terminated by a signal + set_runtime_status(task.name, "FAILED") task.result_info["end_time"] = get_current_time_string() except: break -- Gitee