From 857e5632282ab19fda385d69d0a99da3a926c842 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 21 Jan 2000 05:55:21 +0000 Subject: fix pidof calls in pidofproc --- rc.d/init.d/functions | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'rc.d') 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 -- cgit v1.2.1