From be989b6beff994f1b06e885ef766f01a6a3c0969 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Mon, 20 Mar 2023 14:17:00 +0800 Subject: [PATCH 34/46] 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 7f36d019..3cede76a 100644 --- a/src/utils/cutils/utils.c +++ b/src/utils/cutils/utils.c @@ -321,6 +321,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; @@ -330,7 +331,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; } @@ -349,7 +350,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