[CRIU] [PATCH 2/2] zdtm: wait all children during cleaning up

Andrey Vagin avagin at openvz.org
Tue Apr 16 04:40:26 EDT 2013


From: Andrew Vagin <avagin at openvz.org>


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/session02.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/test/zdtm/live/static/session02.c b/test/zdtm/live/static/session02.c
index 0638b87..edd1b4c 100644
--- a/test/zdtm/live/static/session02.c
+++ b/test/zdtm/live/static/session02.c
@@ -28,7 +28,7 @@ int current = 0;
 
 static void cleanup()
 {
-	int i;
+	int i, ret;
 
 	for (i = 0; i < nr_processes; i++) {
 		if (processes[i].dead)
@@ -38,6 +38,16 @@ static void cleanup()
 
 		kill(processes[i].pid, SIGKILL);
 	}
+
+	while (1) {
+		ret = wait(NULL);
+		if (ret == -1) {
+			if (errno == ECHILD)
+				break;
+			err("wait");
+			exit(1);
+		}
+	}
 }
 
 enum commands
@@ -216,6 +226,11 @@ int main(int argc, char ** argv)
 
 	test_init(argc, argv);
 
+	if (prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0) == -1) {
+		err("PR_SET_CHILD_SUBREAPER");
+		return -1;
+	}
+
 	processes = mmap(NULL, PAGE_SIZE, PROT_WRITE | PROT_READ,
 				MAP_SHARED | MAP_ANONYMOUS, 0, 0);
 	if (processes == NULL) {
-- 
1.8.2



More information about the CRIU mailing list