I have a bash script, this one:
Code:
#!/usr/local/bin/bash
pidfile=/var/dchub/pid
hubscript=/var/dchub/DCHub.py
python=/usr/local/bin/python
if [ -e $pidfile ]
then
#check for running process
hubpid=`cat $pidfile`
if [ `kill -CHLD $hubpid >/dev/null 2>&1` ]
then
exit 0
else
echo "The hub is dead; long live the hub!"
$python $hubscript
fi
else
echo "The hub is dead; long live the hub!"
$python $hubscript
fi
Its purpose is to check py-dchub's pid file and if it is non-existant or if their is no process associated with the pid in the file, to restart py-dchub. I have been able to gather that sending the SIGCHLD signal to a process will be ignored by the process, but you can test the exit status of kill to see if the process exists or not, but for some reason, kill is always returning '0'. Whenever I run the script it attempts to start py-dchub, whether or not it is already running. What am I doing wrong?
I am using bash 3.1.10_1 straight from the FreeBSD RELEASE-6.1 packages.
Thanks