[CRIU] [PATCH] zdtm: exit a test if the "root" process died

Andrei Vagin avagin at openvz.org
Mon Dec 12 16:15:24 PST 2016


From: Andrei Vagin <avagin at virtuozzo.com>

Each test has a process which controls other processes and
if it dies the other processes have to be killed.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 test/zdtm/lib/ns.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index fa6ee86..c70c312 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -344,8 +344,22 @@ int ns_init(int argc, char **argv)
 
 	ret = 0;
 	if (reap) {
-		while (ret != -1)
-			ret = wait(NULL);
+		while (true) {
+			pid_t child;
+			ret = -1;
+
+			child = waitpid(-1, &ret, 0);
+			if (child < 0) {
+				fprintf(stderr, "Unable to wait a test process: %m");
+				exit(1);
+			}
+			if (child == pid) {
+				fprintf(stderr, "The test returned 0x%x", ret);
+				exit(!(ret == 0));
+			}
+			if (ret)
+				fprintf(stderr, "The %d process exited with 0x%x", child, ret);
+		}
 	} else {
 		waitpid(pid, NULL, 0);
 	}
-- 
2.7.4



More information about the CRIU mailing list