]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Fix initscript exit codes.
authorJan Safranek <jsafrane@redhat.com>
Mon, 2 Aug 2010 14:30:45 +0000 (16:30 +0200)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Mon, 2 Aug 2010 16:08:45 +0000 (21:38 +0530)
Fix initscript exit codes
 - propagate errors from functions to final exit status
 - use exit status '1' for generic errors
 - return status '2' when the service is called with unknown arguments

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
scripts/init.d/cgconfig.in
scripts/init.d/cgred.in

index d716b4090e16cdc42665b06893431cca92d0fae3..773df8ade4892397c5c7794dd4d9da519d73fb27 100644 (file)
@@ -52,6 +52,8 @@ if [ -e /etc/sysconfig/cgconfig ]; then
         . /etc/sysconfig/cgconfig
 fi
 
+RETVAL=0
+
 create_default_groups() {
         declare defaultcgroup
 
@@ -107,7 +109,7 @@ start() {
        if [ -f /var/lock/subsys/$servicename ]
         then
             log_warning_msg "lock file already exists"
-            return
+            return 0
         fi
 
         if [ $? -eq 0 ]
@@ -123,7 +125,7 @@ start() {
                 if [ $retval -ne 0 ]
                 then
                     log_failure_msg "Failed to parse " $CONFIG_FILE
-                    return $retval
+                    return 1
                 fi
         fi
 
@@ -136,7 +138,7 @@ start() {
         if [ $retval -ne 0 ]
         then
             log_failure_msg "Failed to touch " /var/lock/subsys/$servicename
-            return $retval
+            return 1
         fi
         log_success_msg
         return 0
@@ -147,6 +149,7 @@ stop() {
     cgclear
     rm -f /var/lock/subsys/$servicename
     log_success_msg
+    return 0
 }
 
 trapped() {
@@ -158,7 +161,7 @@ trapped() {
 
 usage() {
     echo "$0 <start|stop|restart|condrestart|status>"
-    exit 1
+    exit 2
 }
 
 common() {
@@ -175,25 +178,30 @@ case $1 in
     'stop')
         common
         stop;
+        RETVAL=$?
         ;;
     'start')
         common
         start;
+        RETVAL=$?
         ;;
     'restart')
         common
        stop
         start
+        RETVAL=$?
         ;;
     'reload')
         common
        stop
         start
+        RETVAL=$?
         ;;
     'condrestart')
         if [ -f /var/lock/subsys/$servicename ] ; then
             stop
             start
+            RETVAL=$?
         fi
         ;;
     'status')
@@ -209,3 +217,5 @@ case $1 in
         usage
         ;;
 esac
+
+exit $RETVAL
index c5b0ed52c2c90f53f718e63ab8b0252868f212ee..4cea5a472c25ceee1c9f59adbf78e2ba7443fb47 100644 (file)
@@ -138,6 +138,7 @@ case "$1" in
                ;;
        *)
                echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+               RETVAL=2
                ;;
 esac