Randy McMurchy wrote:
> Hi all,
>
> I believe I've run across a bug in the LFS Bootscripts. It appears to
> me that if the concerned script (I've only tested BLFS scripts, but I
> suppose I could kill the sysklog stuff and try it) is not started, and
> you issue a
>
> /etc/rc.d/init.d/script status
>
> command, it will report that it is running, even though it is not.
>
Non-Technical explanation: I actually tested fully (I believe) and it
works!!! :-D
Technical explanation (This is probably only useful to people who would
like to make changes to the functions file): A few changes. getpids()
now works as expected. To keep the output of pidofproc() LSB compliant,
I had to extend the LSB function to include a new switch ([-s] #silent),
which is used throughout the scripts now instead of redirecting the
output to /dev/null. This made the patch a lot bigger. Everything is
still dependent on ${pidlist}, but pidlist is not local to the function
anymore, therefor should not be assigned a value by the output of
pidofproc() when no PIDFILE is present, but rather the output of
pidofproc() is obtained from ${pidlist} in both cases now. In short,
the functionality is the same unless you add the -s switch, but there is
no need to assign the output to a pidlist if you need it.
That was annoying. Anyway, patch against 3.2.2 attached. Should apply
to svn and enhanced in svn/contrib as well. Please report back right
away if you have any problems.
Thanks.
-- DJ Lucas
diff -Naur lfs-bootscripts-3.2.2-orig/lfs/init.d/functions lfs-bootscripts-3.2.2/lfs/init.d/functions
--- lfs-bootscripts-3.2.2-orig/lfs/init.d/functions 2005-03-30 17:19:33.000000000 -0600
+++ lfs-bootscripts-3.2.2/lfs/init.d/functions 2005-08-09 23:43:26.000000000 -0500
@@ -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}" [EMAIL PROTECTED]
+ pidofproc -s -p "${PIDFILE}" $@
else
- pidlist=`pidofproc [EMAIL PROTECTED]
+ 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,9 +704,9 @@
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
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page