aboutsummaryrefslogtreecommitdiffstats
path: root/rc.d
diff options
context:
space:
mode:
Diffstat (limited to 'rc.d')
-rwxr-xr-xrc.d/init.d/functions24
1 files changed, 22 insertions, 2 deletions
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
index 86d1c3c0..24e99948 100755
--- a/rc.d/init.d/functions
+++ b/rc.d/init.d/functions
@@ -101,8 +101,8 @@ daemon() {
# Save basename.
[ -z $gotbase ] && base=`basename $1`
- # See if it's already running.
- pidlist=`pidofproc $1`
+ # See if it's already running. Look *only* at the pid file.
+ pidlist=`pidfileofproc $1`
pid=
for apid in $pidlist ; do
@@ -197,6 +197,26 @@ killproc() {
return $RC
}
+# A function to find the pid of a program. Looks *only* at the pidfile
+pidfileofproc() {
+ base=`basename $1`
+
+ # Test syntax.
+ if [ $# = 0 ] ; then
+ echo $"Usage: pidofproc {program}"
+ return 1
+ fi
+
+ # First try "/var/run/*.pid" files
+ if [ -f /var/run/${base}.pid ] ; then
+ pid=`cat /var/run/${base}.pid | { read foo ; echo $foo ; }`
+ if [ "$pid" != "" ] ; then
+ echo $pid
+ return 0
+ fi
+ fi
+}
+
# A function to find the pid of a program.
pidofproc() {
base=`basename $1`