I'm looking at an init.d script written by a previous coworker which is not functioning correctly now. It's running on centos-6
After some experimentation I found the cause of the issue. He wrote the script to wait up to 30 seconds for a kill -TERM command to runciton before reporting an error. To do this he is running the command:
kill -0 $pid
to test if the killed program has died yet.
The kill -0 command is throwing an error:
/etc/init.d/celerybeat line 211: kill (<pid>) - No such process
it then exists immediately after this line fails.
This is what I would expect with set -e, but the script does not run set -e. In fact it has the line commented out with a comment saying that the kill -0 command will fail if it's set, so he was very aware he didn't want it set.
This happens rather I run it via service or run the script direclty from the /etc/init.d directory
So..why is the script running as if set -e is set? and more importantly, how do I prevent it from running that way, or rewrite the line to check if the pid is running without throwing an exception?