Skip to content

Commit

Permalink
test/timeout: properly loop around waitpid() status
Browse files Browse the repository at this point in the history
We should loop until WIFEXITED() is true.

Link: #1207
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 31, 2024
1 parent becdca8 commit 59c0cb3
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 59c0cb3

Please sign in to comment.