aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrc.d/init.d/functions19
1 files changed, 17 insertions, 2 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index bd8c3eb8..6f1ce97c 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -183,11 +183,17 @@ pidofproc() {
fi
# Next try "pidof"
- pid=`pidof -x $1`
+ pid=`pidof $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() {
@@ -198,10 +204,19 @@ status() {
fi
# First try "pidof"
- pid=`pidof -x $1`
+ pid=`pidof $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