Commit 51672da0 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

test/vhost: Clean up vhost_kill



Change-Id: Id3fe2ecf72bc04a39c0e866d6db57bdb94beb510
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461390


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 9d1e4260
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -174,7 +174,8 @@ function vhost_kill()
		return 0
	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
		warning "no vhost pid file found"
@@ -185,19 +186,19 @@ function vhost_kill()
	local vhost_pid="$(cat $vhost_pid_file)"
	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"
		for ((i=0; i<60; i++)); do
			if /bin/kill -0 $vhost_pid; then
			if kill -0 $vhost_pid; then
				echo "."
				sleep 1
			else
				break
			fi
		done
		if /bin/kill -0 $vhost_pid; then
		if kill -0 $vhost_pid; then
			error "ERROR: vhost was NOT killed - sending SIGABRT"
			/bin/kill -ABRT $vhost_pid
			kill -ABRT $vhost_pid
			rm $vhost_pid_file
			rc=1
		else
@@ -205,11 +206,11 @@ function vhost_kill()
				echo "."
			done
		fi
	elif /bin/kill -0 $vhost_pid; then
	elif kill -0 $vhost_pid; then
		error "vhost NOT killed - you need to kill it manually"
		rc=1
	else
		notice "vhost was no running"
		notice "vhost was not running"
	fi

	timing_exit vhost_kill
@@ -217,6 +218,8 @@ function vhost_kill()
		rm $vhost_pid_file
	fi

	rm -rf "$vhost_dir"

	return $rc
}