From ea8962c6ee3ed05cfabe84c58c47cf56e3388242 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Mon, 20 Mar 2023 14:17:00 +0800 Subject: [PATCH 46/53] modify the return value of the util_waitpid_with_timeout to status Signed-off-by: zhongtao --- src/utils/cutils/utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/cutils/utils.c b/src/utils/cutils/utils.c index 983d81d8..3500d8f8 100644 --- a/src/utils/cutils/utils.c +++ b/src/utils/cutils/utils.c @@ -319,6 +319,7 @@ rep: int util_waitpid_with_timeout(pid_t pid, const int64_t timeout, handle_timeout_callback_t cb) { int nret = 0; + int st; time_t start_time = time(NULL); time_t end_time; double interval; @@ -328,7 +329,7 @@ int util_waitpid_with_timeout(pid_t pid, const int64_t timeout, handle_timeout_c } for (;;) { - nret = waitpid(pid, NULL, WNOHANG); + nret = waitpid(pid, &st, WNOHANG); if (nret == pid) { break; } @@ -347,7 +348,7 @@ int util_waitpid_with_timeout(pid_t pid, const int64_t timeout, handle_timeout_c // sleep some time instead to avoid cpu full running and then retry. usleep(100); } - return 0; + return st; } int util_wait_for_pid_status(pid_t pid) -- 2.25.1