Subject: [PATCH 3/3] rc.d/vkernel: pidfile related enhancements

From: Rumko <[email-masked]>
Date: Sun, 10 Oct 2010 20:21:35 +0200

Fix a typo when checking for the pid file when starting a vkernel.
Better checking if the vkernel being started is already running.
---
 etc/rc.d/vkernel |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/etc/rc.d/vkernel b/etc/rc.d/vkernel
index e3a0316..4453756 100644
--- a/etc/rc.d/vkernel
+++ b/etc/rc.d/vkernel
@@ -18,10 +18,13 @@ vkernel_start()
 	do
 		# Check if already running
 		eval pidfile="/var/run/vkernel.${_vkernel}.pid"
-		if [ -f "${_pidfile}" ]; then
-			echo
-			warn "Vkernel ${_vkernel} already running? (check ${pidfile})"
-			continue
+		if [ -f "${pidfile}" ]; then
+			eval pid=`cat ${pidfile}`
+			if [ ! -z "${pid}" -a ! -z "`ps axwwp ${pid} | grep -wE "^[ ]+${pid}" | grep -v grep | awk '{print $1}'`" ]; then
+				echo
+				warn "Vkernel ${_vkernel} already running? (check ${pidfile})"
+				continue
+			fi
 		fi
 
 		# Configure vkernel binary
-- 
1.7.0.5