Hi Jan, Thank you for your review :-)
Jan Safranek wrote: >> 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 Thanks, I see. I understand the exit code of an init script as you said. My patch was wrong. I think the real problem is the message [FAILED], because an init scripts shall ensure that they will behave sensibly if invoked with start when the service is already running, or with stop when not running. The attached patch changes the message [FAILED] to [ OK ]. How about the attached patch ? >> 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. Ok, the attached patch fixes the above problem also. Thanks Ken'ichi Ohmichi --- [PATCH-v3] Fix returning values and messages of service "cgred". Hi, Changelog since v2: * Fix returning values and messages according to LSB: An init scripts shall ensure that they will behave sensibly if invoked 1. with start when the service is already running 2. or with stop when not running. Changelog since v1: * Fix a returning value of `service cgred reload` also. This patch fixes returning values and messages of service "cgred" according to LSB: An init scripts shall ensure that they will behave sensibly if invoked 1. with start when the service is already running 2. or with stop when not running. Problem 1) "cgred" prints "FAILED" if starting "cgred" twice: # service cgred start Starting CGroup Rules Engine Daemon... cgred is already running with PID 17680 [FAILED] # echo $? 0 # Problem 2) "cgred" prints "FAILED" if reloading "cgred" on the stop of service: # service cgred status cgrulesengd is stopped # service cgred reload cgred is not running. [FAILED] # echo $? 0 # Problem 3) "cgred" returns 7 when stopping "cgred" twice: # service cgred stop Stopping CGroup Rules Engine Daemon... [ OK ] # echo $? 7 # 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 | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in index db9c2ac..3d06ddd 100644 --- a/scripts/init.d/cgred.in +++ b/scripts/init.d/cgred.in @@ -64,8 +64,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 + log_success_msg "$servicename is already running with PID `cat ${pidfile}`" + return fi daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS RETVAL=$? @@ -83,8 +83,13 @@ stop() if [ $RETVAL -eq 0 ] ; then rm -f /var/lock/subsys/$servicename rm -f $pidfile + log_success_msg + elif [ $RETVAL -eq 7 ] ; then + log_success_msg "$servicename is not running." + RETVAL=0 + else + log_failure_msg fi - log_success_msg } # See how we are called @@ -120,7 +125,7 @@ case "$1" in log_failure_msg fi else - log_failure_msg "$servicename is not running." + log_success_msg "$servicename is not running." 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
