test/vhost: Clean up vhost_kill

Change-Id: Id3fe2ecf72bc04a39c0e866d6db57bdb94beb510
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461390
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Ben Walker 2019-06-05 15:17:04 -07:00 committed by Jim Harris
parent 9d1e4260cb
commit 51672da05b

View File

@ -174,7 +174,8 @@ function vhost_kill()
return 0 return 0
fi fi
local vhost_pid_file="$(get_vhost_dir $vhost_name)/vhost.pid" local vhost_dir="$(get_vhost_dir $vhost_name)"
local vhost_pid_file="$vhost_dir/vhost.pid"
if [[ ! -r $vhost_pid_file ]]; then if [[ ! -r $vhost_pid_file ]]; then
warning "no vhost pid file found" warning "no vhost pid file found"
@ -185,19 +186,19 @@ function vhost_kill()
local vhost_pid="$(cat $vhost_pid_file)" local vhost_pid="$(cat $vhost_pid_file)"
notice "killing vhost (PID $vhost_pid) app" notice "killing vhost (PID $vhost_pid) app"
if /bin/kill -INT $vhost_pid >/dev/null; then if kill -INT $vhost_pid > /dev/null; then
notice "sent SIGINT to vhost app - waiting 60 seconds to exit" notice "sent SIGINT to vhost app - waiting 60 seconds to exit"
for ((i=0; i<60; i++)); do for ((i=0; i<60; i++)); do
if /bin/kill -0 $vhost_pid; then if kill -0 $vhost_pid; then
echo "." echo "."
sleep 1 sleep 1
else else
break break
fi fi
done done
if /bin/kill -0 $vhost_pid; then if kill -0 $vhost_pid; then
error "ERROR: vhost was NOT killed - sending SIGABRT" error "ERROR: vhost was NOT killed - sending SIGABRT"
/bin/kill -ABRT $vhost_pid kill -ABRT $vhost_pid
rm $vhost_pid_file rm $vhost_pid_file
rc=1 rc=1
else else
@ -205,11 +206,11 @@ function vhost_kill()
echo "." echo "."
done done
fi fi
elif /bin/kill -0 $vhost_pid; then elif kill -0 $vhost_pid; then
error "vhost NOT killed - you need to kill it manually" error "vhost NOT killed - you need to kill it manually"
rc=1 rc=1
else else
notice "vhost was no running" notice "vhost was not running"
fi fi
timing_exit vhost_kill timing_exit vhost_kill
@ -217,6 +218,8 @@ function vhost_kill()
rm $vhost_pid_file rm $vhost_pid_file
fi fi
rm -rf "$vhost_dir"
return $rc return $rc
} }