mkuthan@pit.edu.pl
Hi. testpid function is failed when concurrent start and stop calls.
Example (concurrent start and stop):
stop: kill $pid
stop: testPid (in while loop)
stop: rm PID (inside testPid)
start: exec wrapper (and create new PID file)
stop: testPid (in SIGKILL section)
stop: rm PID (inside testPid)
start: pid file is missing !!!!!
I rewrite testpid unix shell (sh) function:
testpid() {
savepid=$pid
filepid=`cat $PIDFILE 2> /dev/null`
pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail
-1`
# extra check (do not remove pid of other process)
if [ "$savepid" != "$filepid" ]; then
return
fi
if [ "X$pid" = "X" ]
then
# Process is gone so remove the pid file.
rm -f $PIDFILE
fi
}