From 178a30869d447ebc8a4d9e243813f5429dc9a950 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 30 Jan 2001 21:24:34 +0000 Subject: for daemon(), look only at the pid file to see if it's running (#17244, others) --- rc.d/init.d/functions | 24 ++++++++++++++++++++++-- 1 file 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` -- cgit v1.2.1