Author: dnicholson
Date: 2007-04-16 15:30:58 -0600 (Mon, 16 Apr 2007)
New Revision: 8073
Modified:
trunk/bootscripts/ChangeLog
trunk/bootscripts/lfs/init.d/functions
Log:
Use pidofproc and respect pidfiles in statusproc
Modified: trunk/bootscripts/ChangeLog
===================================================================
--- trunk/bootscripts/ChangeLog 2007-04-16 21:24:57 UTC (rev 8072)
+++ trunk/bootscripts/ChangeLog 2007-04-16 21:30:58 UTC (rev 8073)
@@ -6,6 +6,9 @@
used was causing issues with the handling of pidfiles. This has been
fixes, and now killproc() will recheck the process if the signal
was TERM (the default) or KILL.
+ * lfs/init.d/functions: statusproc() has been changed to use pidofproc()
+ instead of the deprecated getpids(). Additionally, it now accepts
+ the -p argument to specify a pidfile.
2007-03-13 Dan Nicholson <[EMAIL PROTECTED]>
* lfs/init.d/functions: If pidofproc() is passed the -p argument
Modified: trunk/bootscripts/lfs/init.d/functions
===================================================================
--- trunk/bootscripts/lfs/init.d/functions 2007-04-16 21:24:57 UTC (rev
8072)
+++ trunk/bootscripts/lfs/init.d/functions 2007-04-16 21:30:58 UTC (rev
8073)
@@ -279,14 +279,47 @@
statusproc()
{
- if [ "${#}" = "0" ]
- then
- echo "Usage: statusproc {program}"
- exit 1
+ local pidfile=""
+ local base=""
+
+ while true
+ do
+ case "${1}" in
+ -p)
+ pidfile="${2}"
+ shift 2
+ ;;
+ -*)
+ log_failure_msg "Unknown Option: ${1}"
+ return 2
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
+ if [ "${#}" != "1" ]; then
+ shift 1
+ log_failure_msg "Usage: statusproc [-p pidfile] pathname"
+ return 2
fi
- getpids "${1}"
+ # Get the process basename
+ base="${1##*/}"
+ # This will ensure compatibility with previous LFS Bootscripts
+ if [ -n "${PIDFILE}" ]; then
+ pidfile="${PIDFILE}"
+ fi
+
+ # Is the process running?
+ if [ -z "${pidfile}" ]; then
+ pidofproc -s "${1}"
+ else
+ pidofproc -s -p "${pidfile}" "${1}"
+ fi
+
if [ -n "${pidlist}" ]; then
${ECHO} -e "${INFO}${base} is running with Process"\
"ID(s) ${pidlist}.${NORMAL}"
@@ -295,9 +328,9 @@
${ECHO} -e "${WARNING}${1} is not running but"\
"/var/run/${base}.pid exists.${NORMAL}"
else
- if [ -n "${PIDFILE}" -a -e "${PIDFILE}" ]; then
+ if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
${ECHO} -e "${WARNING}${1} is not running"\
- "but ${PIDFILE} exists.${NORMAL}"
+ "but ${pidfile} exists.${NORMAL}"
else
${ECHO} -e "${INFO}${1} is not
running.${NORMAL}"
fi
--
http://linuxfromscratch.org/mailman/listinfo/lfs-book
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page