[CRIU] [PATCH] zdtm/s390x_regs_check: Fix wait() for threads
Michael Holzheu
holzheu at linux.vnet.ibm.com
Wed Sep 27 18:21:48 MSK 2017
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: Adrian Reber <areber at redhat.com>
Signed-off-by: Michael Holzheu <holzheu at linux.vnet.ibm.com>
---
test/zdtm/static/s390x_regs_check.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/static/s390x_regs_check.c b/test/zdtm/static/s390x_regs_check.c
index a92679ab0..4854b534a 100644
--- a/test/zdtm/static/s390x_regs_check.c
+++ b/test/zdtm/static/s390x_regs_check.c
@@ -391,7 +391,10 @@ static void child_func(void)
static int ptrace_attach(pid_t pid)
{
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;
}
pr_perror("Attach to thread %d failed", pid);
--
2.11.0
More information about the CRIU
mailing list