[CRIU] [PATCH 2/2] zdtm: show a process tree before and after c/r

Andrey Vagin avagin at openvz.org
Thu Mar 28 16:01:56 EDT 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh       |  6 +++++-
 test/zdtm/lib/ns.c | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index cf42d05..31b2cbd 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -186,11 +186,15 @@ construct_root()
 {
 	local root=$1
 	local test_path=$2
+	local ps_path=`type -P ps`
 	local libdir=$root/lib
 	local libdir2=$root/lib64
 
+	mkdir $root/bin
+	cp $ps_path $root/bin
+
 	mkdir $libdir $libdir2
-	for i in `ldd $test_path | awk '{ print $1 }' | grep -v vdso`; do
+	for i in `ldd $test_path $ps_path | awk '/^\s/{ print $1 }' | grep -v vdso`; do
 		local lib=`basename $i`
 		[ -f $libdir/$lib ] && continue ||
 		[ -f $i ] && cp $i $libdir && cp $i $libdir2 && continue ||
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 5eb8186..ead4522 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -210,6 +210,13 @@ int ns_init(int argc, char **argv)
 	ret = 1;
 	waitpid(pid, &ret, 0);
 
+
+	pid = fork();
+	if (pid == 0) {
+		execl("/bin/ps", "ps", "axf", "-o", "pid,sid,comm", NULL);
+	} else if (pid > 0)
+		waitpid(pid, NULL, 0);
+
 	/* Daemonize */
 	write(status_pipe, &ret, sizeof(ret));
 	close(status_pipe);
@@ -219,6 +226,12 @@ int ns_init(int argc, char **argv)
 	/* suspend/resume */
 	test_waitsig();
 
+	pid = fork();
+	if (pid == 0) {
+		execl("/bin/ps", "ps", "axf", "-o", "pid,sid,comm", NULL);
+	} else if (pid > 0)
+		waitpid(pid, NULL, 0);
+
 	fd = open(pidfile, O_RDONLY);
 	if (fd == -1) {
 		fprintf(stderr, "open(%s) failed: %m\n", pidfile);
-- 
1.7.11.7



More information about the CRIU mailing list