[CRIU] [PATCH] zdtm.sh: wait page-server by a proper way

Andrey Vagin avagin at openvz.org
Tue Jul 23 16:00:05 EDT 2013


page-server is forked and the child is running in background, so a bash
variable $! contains PID of the last command, which is executed in
background.

Currently it's tcpdump and zdtm.sh is waiting it and never returns back.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 9749b90..6d13463 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -322,6 +322,7 @@ run_test()
 	local linkremap=
 	local snapopt=
 	local snappdir=
+	local ps_pid=
 
 	[ -n "$EXCLUDE_PATTERN" ] && echo $test | grep "$EXCLUDE_PATTERN" && return 0
 
@@ -376,8 +377,12 @@ EOF
 		mkdir -p $ddump
 
 		if [ $PAGE_SERVER -eq 1 ]; then
-			$CRIU page-server -D $ddump -o page_server.log -v4 --port $PS_PORT --daemon
-			PS_PID=$!
+			$CRIU page-server -D $ddump -o page_server.log -v4 --port $PS_PORT --daemon || return 1
+			ps_pid=`lsof -s TCP:LISTEN -i :$PS_PORT -t`
+			ps -p "$ps_pid" -o cmd h | grep -q page-server || {
+				echo "Unable to determing PID of page-server"
+				return 1
+			}
 			opts="--page-server --address 127.0.0.1 --port $PS_PORT"
 		fi
 
@@ -400,7 +405,11 @@ EOF
 		fi
 
 		if [ $PAGE_SERVER -eq 1 ]; then
-			wait $PS_PID
+			while :; do
+				kill -0 $ps_pid > /dev/null 2>&1 || break;
+				echo Waiting the process $ps_pid
+				sleep 0.1
+			done
 		fi
 
 		if expr " $ARGS" : ' -s' > /dev/null; then
-- 
1.8.3.1



More information about the CRIU mailing list