aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d/init.d
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2000-01-21 05:55:21 +0000
committerBill Nottingham <notting@redhat.com>2000-01-21 05:55:21 +0000
commit857e5632282ab19fda385d69d0a99da3a926c842 (patch)
treef5099567fb5f9d16c852491d0209cb74c62fb407 /rc.d/init.d
parent7a7946ddfb32d33e0529c4362d8efd76781a4784 (diff)
downloadinitscripts-857e5632282ab19fda385d69d0a99da3a926c842.tar
initscripts-857e5632282ab19fda385d69d0a99da3a926c842.tar.gz
initscripts-857e5632282ab19fda385d69d0a99da3a926c842.tar.bz2
initscripts-857e5632282ab19fda385d69d0a99da3a926c842.tar.xz
initscripts-857e5632282ab19fda385d69d0a99da3a926c842.zip
fix pidof calls in pidofproc
Diffstat (limited to 'rc.d/init.d')
-rwxr-xr-xrc.d/init.d/functions34
1 files changed, 15 insertions, 19 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 6f1ce97c..25370f9f 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -82,7 +82,13 @@ daemon() {
[ -z $gotbase ] && base=`basename $1`
# See if it's already running.
- pid=`pidofproc $base`
+ pidlist=`pidofproc $base`
+
+ pid=
+ for apid in $pidlist ; do
+ [ -d /proc/$apid ] && pid="$pid $apid"
+ done
+
[ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && return
# make sure it doesn't core dump anywhere; while this could mask
@@ -122,7 +128,12 @@ killproc() {
base=`basename $1`
# Find pid.
- pid=`pidofproc $base`
+ pidlist=`pidofproc $base`
+
+ pid=
+ for apid in $pidlist ; do
+ [ -d /proc/$apid ] && pid="$pid $apid"
+ done
# Kill it.
if [ "$pid" != "" ] ; then
@@ -183,17 +194,11 @@ pidofproc() {
fi
# Next try "pidof"
- pid=`pidof $1`
+ pid=`pidof -o $$ -o $PPID -o %PPID -x $1`
if [ "$pid" != "" ] ; then
echo $pid
return 0
fi
-
- # Finally try to extract it from ps
- ps ax | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
- { if ((prog == $5) || (("(" prog ")") == $5) ||
- (("[" prog "]") == $5) ||
- ((prog ":") == $5)) { print $1 ; exit 0 } }' $1
}
status() {
@@ -204,19 +209,10 @@ status() {
fi
# First try "pidof"
- pid=`pidof $1`
+ pid=`pidof -o $$ -o $PPID -o %PPID -x $1`
if [ "$pid" != "" ] ; then
echo "$1 (pid $pid) is running..."
return 0
- else
- pid=`ps ax | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
- { if ((prog == $5) || (("(" prog ")") == $5) ||
- (("[" prog "]") == $5) ||
- ((prog ":") == $5)) { print $1 ; exit 0 } }' $1`
- if [ "$pid" != "" ] ; then
- echo "$1 (pid $pid) is running..."
- return 0
- fi
fi
# Next try "/var/run/*.pid" files