Listing 2: Shell script to confirm a process kill

 #!/bin/sh
 if [ "${#}" -ne 1 ]; then
 	echo "Usage: ${0} PID" 1>&2
 	exit 255
 fi
 
 kill -0 ${1}
 if [ "${?}" -eq 0 ]; then
 	kill -HUP "${1}"
 	if [ "${?}" -ne 0 ]; then
 		echo "kill -HUP ${1} failed with exit status ${?}" 1>&2
 		exit 1;
 	fi
 	kill -0 ${1} >/dev/null 2>&1
 	if [ "${?}" -eq 0 ]; then
         	kill -TERM "${1}"
 	        if [ "${?}" -ne 0 ]; then
         	        echo "kill -TERM ${1} failed with exit status ${?}" 1>&2
 	                exit 1;
 	        fi
 		kill -0 ${1} >/dev/null 2>&1
 		if [ "${?}" -eq 0 ]; then
 		        kill -KILL "${1}"
 		        if [ "${?}" -ne 0 ]; then
 		                echo "kill -KILL ${1} failed with exit status ${?}" 1>&2
 		                exit 1;
 		        fi
 		fi
 	fi
 else
 	echo "Kill -0 ${1} failed!" 1>&2
 	exit 1;
 fi

