tags:

views:

161

answers:

1

Hi,

We have a Linux Daemon in c and a bash script to start it. The daemon sometimes fail to start because of some configuration file errors but the script reports the daemon was started successfully. A snippet of the script is shown as below, could someone tell me what's wrong with the script?

...
case "$1" in
start)
echo -n "Starting Demo Daemon: "
sudo -u demouser env DEMO_HOME=$DEMO_HOME /usr/local/demouser/bin/democtl startup > /dev/null 2> /dev/null
if [ "$?" = "0" ]; then
    echo_success
else
    echo_failure
fi
echo
;;
...

Thanks!

+5  A: 

I feel there is nothing wrong with the script,it is the reponsibility of daemon to return non zero exit status if failed to start properly and based on those the script will display the message.(which i think it does)

Neeraj
Both `sudo` and `env` preserve the exit code, so it's probably really the daemon itself which doesn't set the correct code.
Aaron Digulla