compat: prefer waitpid() over waitid()

while both are defined by POSIX, waitpid() is more common than waitid().

Signed-off-by: Sebastien Marie <semarie@online.fr>
This commit is contained in:
Sébastien Marie 2024-01-19 16:08:21 +00:00 committed by Daniel Stone
parent a74aa93394
commit 791912c678
2 changed files with 19 additions and 27 deletions

View file

@ -315,7 +315,7 @@ int main(int argc, char *argv[])
const struct test *t;
pid_t pid;
int total, pass;
siginfo_t info;
int info;
if (isatty(fileno(stderr)))
is_atty = 1;
@ -358,37 +358,32 @@ int main(int argc, char *argv[])
if (pid == 0)
run_test(t); /* never returns */
if (waitid(P_PID, pid, &info, WEXITED)) {
if (waitpid(pid, &info, 0) == -1) {
stderr_set_color(RED);
fprintf(stderr, "waitid failed: %s\n",
fprintf(stderr, "waitpid failed: %s\n",
strerror(errno));
stderr_reset_color();
abort();
}
switch (info.si_code) {
case CLD_EXITED:
if (info.si_status == EXIT_SUCCESS)
if (WIFEXITED(info)) {
if (WEXITSTATUS(info) == EXIT_SUCCESS)
success = !t->must_fail;
else
success = t->must_fail;
stderr_set_color(success ? GREEN : RED);
fprintf(stderr, "test \"%s\":\texit status %d",
t->name, info.si_status);
t->name, WEXITSTATUS(info));
break;
case CLD_KILLED:
case CLD_DUMPED:
} else if (WIFSIGNALED(info)) {
if (t->must_fail)
success = 1;
stderr_set_color(success ? GREEN : RED);
fprintf(stderr, "test \"%s\":\tsignal %d",
t->name, info.si_status);
break;
t->name, WTERMSIG(info));
}
if (success) {