#!/bin/bash
# parameter 1: process

pid=$1
retry_count=20

kill $pid || true

counter=0
while [ $counter -lt $retry_count ]; do
	ps $pid >/dev/null 2>&1
	ret=$?
	if [ "$ret" != "0" ]; then
		echo "process $pid already exit"
		exit 0
	fi
	((counter += 1))
	sleep 0.5
	kill $pid || true
	echo "wait process $pid exit for $counter-th time..."
done

echo "wait process $pid exit timeout"
exit 1
