From 59c0cb35771036db10a6d8c1ab8574135e0f4161 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 30 Oct 2024 19:04:39 -0600 Subject: [PATCH] test/timeout: properly loop around waitpid() status We should loop until WIFEXITED() is true. Link: https://github.com/axboe/liburing/issues/1207 Signed-off-by: Jens Axboe --- test/timeout.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/timeout.c b/test/timeout.c index 06474ca53..6a8276b4b 100644 --- a/test/timeout.c +++ b/test/timeout.c @@ -1228,14 +1228,19 @@ static int test_timeout_link_cancel(void) exit(0); } - if (waitpid(p, &wstatus, 0) == (pid_t)-1) { - perror("waitpid()"); - return 1; - } - if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus)) { - fprintf(stderr, "child failed %i\n", WEXITSTATUS(wstatus)); - return 1; - } + do { + if (waitpid(p, &wstatus, 0) == (pid_t)-1) { + perror("waitpid()"); + return 1; + } + if (!WIFEXITED(wstatus)) + continue; + if (WEXITSTATUS(wstatus)) { + fprintf(stderr, "child failed %i\n", WEXITSTATUS(wstatus)); + return 1; + } + break; + } while (1); for (i = 0; i < 2; ++i) { ret = io_uring_wait_cqe(&ring, &cqe);