r6689 - in trunk/bootscripts: . contrib/enhanced/init.d lfs/init.d

dj at linuxfromscratch.org dj at linuxfromscratch.org
Sun Aug 14 21:11:24 PDT 2005


Author: dj
Date: 2005-08-14 22:11:24 -0600 (Sun, 14 Aug 2005)
New Revision: 6689

Modified:
   trunk/bootscripts/CHANGELOG
   trunk/bootscripts/contrib/enhanced/init.d/functions
   trunk/bootscripts/lfs/init.d/functions
Log:
Fixed output of pidofproc/statusproc.

Modified: trunk/bootscripts/CHANGELOG
===================================================================
--- trunk/bootscripts/CHANGELOG	2005-08-14 23:27:25 UTC (rev 6688)
+++ trunk/bootscripts/CHANGELOG	2005-08-15 04:11:24 UTC (rev 6689)
@@ -1,3 +1,9 @@
+n/a - August 14, 2005
+	* Added -s flag to pidofproc() for backwards 
+	  compatibility (DJ Lucas)
+	* Fixed erronous values returned by pidofproc() which 
+	  broke the functionality of statusproc (DJ Lucas)
+
 n/a - July 1, 2005
 	* Changed a == to a = in lfs/init.d/functions, in the boot_mesg
 	  function for ash compliancy (Nathan Coulson)

Modified: trunk/bootscripts/contrib/enhanced/init.d/functions
===================================================================
--- trunk/bootscripts/contrib/enhanced/init.d/functions	2005-08-14 23:27:25 UTC (rev 6688)
+++ trunk/bootscripts/contrib/enhanced/init.d/functions	2005-08-15 04:11:24 UTC (rev 6689)
@@ -409,7 +409,7 @@
 # The below functions are documented in the LSB-generic 2.1.0
 
 #*******************************************************************************
-# Function - pidofproc [-p pidfile] pathname
+# Function - pidofproc [-s] [-p pidfile] pathname
 #
 # Purpose: This function returns one or more pid(s) for a particular daemon
 #
@@ -432,7 +432,8 @@
 {
 	local pidfile=""
 	local lpids=""
-	local pidlist=""
+	local silent=""
+	pidlist=""
 	while true
 	do
 		case "${1}" in
@@ -440,6 +441,13 @@
 				pidfile="${2}"
 				shift 2
 				;;
+
+			-s)
+				# Added for legacy opperation of getpids
+				# eliminates several '> /dev/null'
+				silent="1"
+				shift 1
+				;;
 			-*)
 				log_failure_msg "Unknown Option: ${1}"
 				return 2
@@ -452,7 +460,7 @@
 
 	if [ "${#}" != "1" ]; then
 		shift 1
-		log_failure_msg "Usage: pidofproc [-p pidfile] pathname"
+		log_failure_msg "Usage: pidofproc [-s] [-p pidfile] pathname"
 		return 2
 	fi
 
@@ -468,13 +476,31 @@
 				kill -0 "${pid}" > /dev/null &&
 				pidlist="${pidlist} ${pid}"
 			fi
-			echo ${pidlist}
-			test -z "${pidlist}" && return 1 # Program is dead, pidfile exists
+			
+			if [ "${silent}" -ne "1" ]; then
+				echo "${pidlist}"
+			fi
+
+			test -z "${pidlist}" && 
+			# Program is dead, pidfile exists
+			return 1
+			# else
 			return 0
 		done
 
 	else
-		pidof -o $$ -o $PPID -x "${1}"
+		pidlist=`pidof -o $$ -o $PPID -x "$1"`
+		if [ "x${silent}" != "x1" ]; then
+			echo "${pidlist}"
+		fi
+
+		# Get provide correct running status
+		if [ -n "${pidlist}" ]; then
+			return 0
+		else
+			return 3
+		fi
+
 	fi
 
 	if [ "$?" != "0" ]; then
@@ -486,9 +512,9 @@
 getpids()
 {
 	if [ -z "${PIDFILE}" ]; then
-		pidlist=`pidofproc -p "${PIDFILE}" $@`
+		pidofproc -s -p "${PIDFILE}" $@
 	else
-		pidlist=`pidofproc $@`
+		pidofproc -s $@
 	fi
 	base="${1##*/}"
 }
@@ -560,9 +586,9 @@
 
 	if [ -z "${forcestart}" ]; then
 		if [ -z "${pidfile}" ];	then
-			pidofproc "${1}" > /dev/null
+			pidofproc -s "${1}"
 		else
-			pidofproc -p "${pidfile}" "${1}" > /dev/null
+			pidofproc -s -p "${pidfile}" "${1}"
 		fi
 
 		case "${?}" in
@@ -612,7 +638,7 @@
 {
 	local pidfile=""
 	local killsig=""
-	local pidlist=""
+	pidlist=""
 
 # This will ensure compatibility with previous LFS Bootscripts
 	if [ -n "${PIDFILE}" ];	then
@@ -645,9 +671,9 @@
 	fi
 
 	if [ -z "${pidfile}" ];	then
-		pidlist=`pidofproc "${1}"`
+		pidofproc -s "${1}"
 	else
-		pidlist=`pidofproc -p "${pidfile}" "${1}"`
+		pidofproc -s -p "${pidfile}" "${1}"
 	fi
 
 	for pid in ${pidlist}
@@ -668,7 +694,7 @@
 	done
 
 	if [ -z "${killsig}" ];	then
-		pidofproc "${1}" > /dev/null
+		pidofproc -s "${1}"
 
 		# Program was terminated
 		if [ "$?" != "0" ]; then
@@ -684,15 +710,17 @@
 		fi
 	else
 		if [ -z "${pidfile}" ];	then
-			pidofproc "${1}" > /dev/null
+			pidofproc -s "${1}"
 		else
-			pidofproc -p "${pidfile}" "${1}" > /dev/null
+			pidofproc -s -p "${pidfile}" "${1}"
 		fi
 	fi
 
 	evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts
+
 }
 
+
 #*******************************************************************************
 # Function - log_success_msg "message"
 #

Modified: trunk/bootscripts/lfs/init.d/functions
===================================================================
--- trunk/bootscripts/lfs/init.d/functions	2005-08-14 23:27:25 UTC (rev 6688)
+++ trunk/bootscripts/lfs/init.d/functions	2005-08-15 04:11:24 UTC (rev 6689)
@@ -403,7 +403,7 @@
 # The below functions are documented in the LSB-generic 2.1.0
 
 #*******************************************************************************
-# Function - pidofproc [-p pidfile] pathname
+# Function - pidofproc [-s] [-p pidfile] pathname
 #
 # Purpose: This function returns one or more pid(s) for a particular daemon
 #
@@ -426,7 +426,8 @@
 {
 	local pidfile=""
 	local lpids=""
-	local pidlist=""
+	local silent=""
+	pidlist=""
 	while true
 	do
 		case "${1}" in
@@ -434,6 +435,13 @@
 				pidfile="${2}"
 				shift 2
 				;;
+
+			-s)
+				# Added for legacy opperation of getpids
+				# eliminates several '> /dev/null'
+				silent="1"
+				shift 1
+				;;
 			-*)
 				log_failure_msg "Unknown Option: ${1}"
 				return 2
@@ -446,7 +454,7 @@
 
 	if [ "${#}" != "1" ]; then
 		shift 1
-		log_failure_msg "Usage: pidofproc [-p pidfile] pathname"
+		log_failure_msg "Usage: pidofproc [-s] [-p pidfile] pathname"
 		return 2
 	fi
 
@@ -462,13 +470,31 @@
 				kill -0 "${pid}" > /dev/null &&
 				pidlist="${pidlist} ${pid}"
 			fi
-			echo ${pidlist}
-			test -z "${pidlist}" && return 1 # Program is dead, pidfile exists
+			
+			if [ "${silent}" -ne "1" ]; then
+				echo "${pidlist}"
+			fi
+
+			test -z "${pidlist}" && 
+			# Program is dead, pidfile exists
+			return 1
+			# else
 			return 0
 		done
 
 	else
-		pidof -o $$ -o $PPID -x "${1}"
+		pidlist=`pidof -o $$ -o $PPID -x "$1"`
+		if [ "x${silent}" != "x1" ]; then
+			echo "${pidlist}"
+		fi
+
+		# Get provide correct running status
+		if [ -n "${pidlist}" ]; then
+			return 0
+		else
+			return 3
+		fi
+
 	fi
 
 	if [ "$?" != "0" ]; then
@@ -480,9 +506,9 @@
 getpids()
 {
 	if [ -z "${PIDFILE}" ]; then
-		pidlist=`pidofproc -p "${PIDFILE}" $@`
+		pidofproc -s -p "${PIDFILE}" $@
 	else
-		pidlist=`pidofproc $@`
+		pidofproc -s $@
 	fi
 	base="${1##*/}"
 }
@@ -554,9 +580,9 @@
 
 	if [ -z "${forcestart}" ]; then
 		if [ -z "${pidfile}" ];	then
-			pidofproc "${1}" > /dev/null
+			pidofproc -s "${1}"
 		else
-			pidofproc -p "${pidfile}" "${1}" > /dev/null
+			pidofproc -s -p "${pidfile}" "${1}"
 		fi
 
 		case "${?}" in
@@ -606,7 +632,7 @@
 {
 	local pidfile=""
 	local killsig=""
-	local pidlist=""
+	pidlist=""
 
 # This will ensure compatibility with previous LFS Bootscripts
 	if [ -n "${PIDFILE}" ];	then
@@ -639,9 +665,9 @@
 	fi
 
 	if [ -z "${pidfile}" ];	then
-		pidlist=`pidofproc "${1}"`
+		pidofproc -s "${1}"
 	else
-		pidlist=`pidofproc -p "${pidfile}" "${1}"`
+		pidofproc -s -p "${pidfile}" "${1}"
 	fi
 
 	for pid in ${pidlist}
@@ -662,7 +688,7 @@
 	done
 
 	if [ -z "${killsig}" ];	then
-		pidofproc "${1}" > /dev/null
+		pidofproc -s "${1}"
 
 		# Program was terminated
 		if [ "$?" != "0" ]; then
@@ -678,15 +704,17 @@
 		fi
 	else
 		if [ -z "${pidfile}" ];	then
-			pidofproc "${1}" > /dev/null
+			pidofproc -s "${1}"
 		else
-			pidofproc -p "${pidfile}" "${1}" > /dev/null
+			pidofproc -s -p "${pidfile}" "${1}"
 		fi
 	fi
 
 	evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts
+
 }
 
+
 #*******************************************************************************
 # Function - log_success_msg "message"
 #




More information about the lfs-book mailing list