r4192 - in trunk/bootscripts: . lfs/init.d

nathan at linuxfromscratch.org nathan at linuxfromscratch.org
Wed Sep 22 20:47:57 PDT 2004


Author: nathan
Date: 2004-09-22 21:47:55 -0600 (Wed, 22 Sep 2004)
New Revision: 4192

Modified:
   trunk/bootscripts/CHANGELOG
   trunk/bootscripts/lfs/init.d/functions
Log:
Fixed getpids to eliminate stale pids from pidlist

Modified: trunk/bootscripts/CHANGELOG
===================================================================
--- trunk/bootscripts/CHANGELOG	2004-09-22 22:29:11 UTC (rev 4191)
+++ trunk/bootscripts/CHANGELOG	2004-09-23 03:47:55 UTC (rev 4192)
@@ -1,5 +1,6 @@
 n/a - September 22, 2004
 	* Removed the dependency on wl by replacing it with grep (Bryan Kadzban)
+	* fixed getpids, to remove unused pids obtained from $PIDFILE
 
 n/a - September 21, 2004
 	* boot_mesg has been enhanced.  Subsequent calls will overwrite previous text,

Modified: trunk/bootscripts/lfs/init.d/functions
===================================================================
--- trunk/bootscripts/lfs/init.d/functions	2004-09-22 22:29:11 UTC (rev 4191)
+++ trunk/bootscripts/lfs/init.d/functions	2004-09-23 03:47:55 UTC (rev 4192)
@@ -200,14 +200,25 @@
 getpids()
 {
 	# Setup Environment
+	local lpids=""
+	local pid=""
 	pidlist=""
 	nopid=""
 
 	# If PIDFILE is set, then we get our pidlist from there
 	if [ -n "${PIDFILE}" ]; then
-		pidlist="$(cat $PIDFILE 2>/dev/null)"
+		lpids="$(cat $PIDFILE 2>/dev/null)"
 		if [ "$?" = "0" ]; then
-			nopid="1"
+			# Sometimes we may have a stale PIDFILE, verify that all pids
+			# are valid
+			for pid in $lpids; do
+				kill -0 $pid 2>/dev/null && pidlist="$pidlist $pid"
+			done
+			if [ -z "$pidlist" ]; then
+				nopid="0"
+			else
+				nopid="1"
+			fi
 		else
 			nopid="0"
 		fi




More information about the lfs-book mailing list