diff --git a/src/services/syssentry/syssentry.py b/src/services/syssentry/syssentry.py index def3ed71760135978230c6bb3618eaf9594d383f..4c46076593591772e212388213dc0ddcb341a4c8 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