[CRIU] [PATCH 3/3] zdtm: Remove unneeded re-exec
Pavel Emelyanov
xemul at parallels.com
Thu Dec 3 04:07:31 PST 2015
When starting inside ns flavor the test_init() routine prepares
the binary to be run inside namespaces. In particular this routine
fork()-s an init, execve()-s one to pick up mappings and exe from
the new mntns and then fork()-s the test itself. In order to go
back to test_init() for test initialization the execve() is done
again, but it's actually not required and confuses the reader.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
test/zdtm/lib/ns.c | 9 ++++-----
test/zdtm/lib/test.c | 3 ---
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 69d2d51..6e44342 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -262,10 +262,9 @@ int ns_init(int argc, char **argv)
fprintf(stderr, "fork() failed: %m\n");
exit(1);
} else if (pid == 0) {
- setenv("ZDTM_NEWNS", "3", 1);
- ret = execvp(argv[0], argv);
- fprintf(stderr, "exec(%s) failed: %m\n", argv[0]);
- return ret;
+ close(status_pipe);
+ unsetenv("ZDTM_NEWNS");
+ return 0; /* Continue normal test startup */
}
ret = -1;
@@ -299,7 +298,7 @@ int ns_init(int argc, char **argv)
write(status_pipe, &ret, sizeof(ret));
close(status_pipe);
if (ret)
- return ret;
+ exit(ret);
/* suspend/resume */
test_waitsig();
diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 9d4ab0f..57b6cf6 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -115,10 +115,7 @@ void test_init(int argc, char **argv)
test_log_init(outfile, "ns");
redir_stdfds();
ns_init(argc, argv);
- exit(1);
}
-
- /* "3" -- run the test */
}
val = getenv("ZDTM_GROUPS");
--
1.9.3
More information about the CRIU
mailing list