mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
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:
parent
a74aa93394
commit
791912c678
2 changed files with 19 additions and 27 deletions
|
|
@ -103,26 +103,23 @@ handle_client_destroy(void *data)
|
|||
{
|
||||
struct client_info *ci = data;
|
||||
struct display *d;
|
||||
siginfo_t status;
|
||||
int status;
|
||||
|
||||
d = ci->display;
|
||||
|
||||
assert(waitid(P_PID, ci->pid, &status, WEXITED) != -1);
|
||||
assert(waitpid(ci->pid, &status, 0) != -1);
|
||||
|
||||
switch (status.si_code) {
|
||||
case CLD_KILLED:
|
||||
case CLD_DUMPED:
|
||||
if (WIFSIGNALED(status)) {
|
||||
fprintf(stderr, "Client '%s' was killed by signal %d\n",
|
||||
ci->name, status.si_status);
|
||||
ci->kill_code = status.si_status;
|
||||
break;
|
||||
case CLD_EXITED:
|
||||
if (status.si_status != EXIT_SUCCESS)
|
||||
fprintf(stderr, "Client '%s' exited with code %d\n",
|
||||
ci->name, status.si_status);
|
||||
ci->name, WTERMSIG(status));
|
||||
ci->kill_code = WTERMSIG(status);
|
||||
|
||||
ci->exit_code = status.si_status;
|
||||
break;
|
||||
} else if (WIFEXITED(status)) {
|
||||
if (WEXITSTATUS(status) != EXIT_SUCCESS)
|
||||
fprintf(stderr, "Client '%s' exited with code %d\n",
|
||||
ci->name, WEXITSTATUS(status));
|
||||
|
||||
ci->exit_code = WEXITSTATUS(status);
|
||||
}
|
||||
|
||||
++d->clients_terminated_no;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue