On 07/13/2009 09:07 AM, Ken'ichi Ohmichi wrote:
> Hi,
>
> Changelog since v1:
>   * Fix a returning value of `service cgred reload` also.
>
>
> This patch fixes returning values and messages of service "cgred".
>
> 1) "cgred" returns 0 (meaning success) even if printing "FAILED"
>     when starting "cgred" again:
>       # service cgred start
>       Starting CGroup Rules Engine Daemon...
>       cgred is already running with PID 17680                 [FAILED]
>       # echo $?
>       0
>       #
>
> 2) "cgred" returns 0 (meaning success) even if printing "FAILED"
>     when reloading "cgred" on the stop of service:
>       # service cgred status
>       cgrulesengd  is stopped
>       # service cgred reload
>       cgred is not running.                                   [FAILED]
>       # echo $?
>       0
>       #
>

Beware, the cases above are correct - LSB explicitly requests that 
starting already running service should result in exit code 0.

The same applies to stopping already stopped service and reloading 
stopped service - exit code 0 is requested here as well.

See 
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html

The cgred init script is correct in these case, but I admit it's more or 
less accident than intention.

>
> 3) "cgred" prints "OK" even if returning !0 when stopping "cgred"
>     again:
>       # service cgred stop
>       Stopping CGroup Rules Engine Daemon...
>                                                               [  OK  ]
>       # echo $?
>       7
>       #
>

This seems to me as real bug.

> By applying this patch, "cgred" prints right messages and returns
> right values.
>
>
> Thanks
> Ken'ichi Ohmichi
>
> Signed-off-by: Ken'ichi Ohmichi<[email protected]>
> ---
>   scripts/init.d/cgred.in |   12 ++++++++++--
>   1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in
> index db9c2ac..d33d43b 100644
> --- a/scripts/init.d/cgred.in
> +++ b/scripts/init.d/cgred.in
> @@ -65,7 +65,8 @@ start()
>       echo $"Starting CGroup Rules Engine Daemon..."
>       if [ -f "/var/lock/subsys/$servicename" ] ; then
>               log_failure_msg "$servicename is already running with PID `cat 
> ${pidfile}`"
> -             return 1
> +             RETVAL=1
> +             return
>       fi
>       daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
>       RETVAL=$?
> @@ -83,8 +84,14 @@ stop()
>       if [ $RETVAL -eq 0 ] ; then
>               rm -f /var/lock/subsys/$servicename
>               rm -f $pidfile
> +             log_success_msg
> +     else
> +             if [ -f /var/lock/subsys/$servicename ] ; then
> +                     log_failure_msg "Process $processname does not exist."
> +             else
> +                     log_failure_msg "$servicename is not running."
> +             fi
>       fi
> -     log_success_msg
>   }
>
>   # See how we are called
> @@ -121,6 +128,7 @@ case "$1" in
>                       fi
>               else
>                       log_failure_msg "$servicename is not running."
> +                     RETVAL=1
>               fi
>               ;;
>       *)
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Libcg-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libcg-devel


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to