Commit 1a79b4d6 authored by Michael Holzheu's avatar Michael Holzheu Committed by Andrei Vagin

zdtm/s390x_regs_check: Fix wait() for threads

For older kernels (e.g. RHEL7 with 3.10) it seems that wait(NULL) after
ptrace(PTHREAD_ATTACH) does not work properly for threads that have
to be created via clone().

Fix this by using waitpid() with the __WALL flag.

>From the waitpid() man page:

 __WALL (since Linux 2.4)
 Wait  for  all  children, regardless of type ("clone" or "non-clone").
Reported-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 74546157
...@@ -391,7 +391,10 @@ static void child_func(void) ...@@ -391,7 +391,10 @@ static void child_func(void)
static int ptrace_attach(pid_t pid) static int ptrace_attach(pid_t pid)
{ {
if (ptrace(PTRACE_ATTACH, pid, 0, 0) == 0) { if (ptrace(PTRACE_ATTACH, pid, 0, 0) == 0) {
wait(NULL); if (waitpid(pid, NULL, __WALL) < 0) {
pr_perror("Waiting for thread %d failed", pid);
return -1;
}
return 0; return 0;
} }
pr_perror("Attach to thread %d failed", pid); pr_perror("Attach to thread %d failed", pid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment