[sr-dev] Again about return code when start action fails

Iñaki Baz Castillo ibc at aliax.net
Fri Jun 10 19:23:23 CEST 2011


2011/6/10 Iñaki Baz Castillo <ibc at aliax.net>:
> 2011/6/10 Iñaki Baz Castillo <ibc at aliax.net>:
>> Ok, it's not a problem in kamailio code, but just in the kamailio init
>> script. It fails and always return 0. I will inspect it.
>
> I've found the problem. The init script is as follows:
>
> ---------------------
> set -e
>
> [...]
>
> case "$1" in
>  start|debug)
>        [...]
>
>        echo -n "Starting $DESC: $NAME"
>        start-stop-daemon --start --quiet --pidfile $PIDFILE \
>                --exec $DAEMON -- $OPTIONS || echo -n " already running"
>        echo "."
>        ;;
> ---------------------
>
> It's very wrong:
>
> - It does not use --oknodo option, so in case the daemon is already
> running the method return 1 and "echo 'already running'" is printed.
> So finally it retuns 0 (OK). Yes, it seems correct but...
>
> - In case start-stop-daemon returns error (!= 0) due to a *real*
> error, then "already running" is also printed so 0 returned. Wrong.


The problem was present in debian init script for "leeny", "squeeze"
and "lucid". However the init script for generic "debian" does the
work correctly.

Anyhow I've improved all the deb init scripts to behave correctly:

  http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=cb30d96052a4ccf7ce9fec627785313cb13bc442

Regards.

-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the sr-dev mailing list