]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools: unify exit() calls outside of main() 1139/head
authorChristian Brauner <cbrauner@suse.de>
Thu, 18 Aug 2016 09:11:34 +0000 (11:11 +0200)
committerChristian Brauner <cbrauner@suse.de>
Thu, 18 Aug 2016 09:11:34 +0000 (11:11 +0200)
This also changes the help exit status of lxc-unshare and lxc-usernsexec. So
far they did exit(EXIT_FAILURE) whereas all other tools do exit(EXIT_SUCCESS).
Let's align them with the rest of the tools. This should be safe to do.

Signed-off-by: Christian Brauner <cbrauner@suse.de>
src/lxc/tools/lxc_clone.c
src/lxc/tools/lxc_config.c
src/lxc/tools/lxc_device.c
src/lxc/tools/lxc_unshare.c
src/lxc/tools/lxc_usernsexec.c

index 6bd2226484f424dadb3ea32bff1075549a9e1858..e7ecd0c5135234618cf7c8619c6fd04a7d97cbc0 100644 (file)
@@ -89,7 +89,7 @@ static void usage(const char *me)
        printf("  -p: use container orig from custom lxcpath\n");
        printf("  -P: create container new in custom lxcpath\n");
        printf("  -R: rename existing container\n");
-       exit(1);
+       exit(EXIT_SUCCESS);
 }
 
 static struct option options[] = {
index 998fa32e8673a455058d80f5fbc1e4b77aa1ffd9..c26b1a0aa8b596fc1b671d7f13c0941eae2e2a81 100644 (file)
@@ -45,7 +45,7 @@ static void usage(char *me)
 {
        printf("Usage: %s -l: list all available configuration items\n", me);
        printf("       %s item: print configuration item\n", me);
-       exit(1);
+       exit(EXIT_SUCCESS);
 }
 
 static void list_config_items(void)
@@ -54,7 +54,7 @@ static void list_config_items(void)
 
        for (i = &items[0]; i->name; i++)
                printf("%s\n", i->name);
-       exit(0);
+       exit(EXIT_SUCCESS);
 }
 
 int main(int argc, char *argv[])
index 9cd7614258c868783c260847d0ad960452287ecd..abf52b9c407bb8b436792f9cf50a40a7e2848a0c 100644 (file)
@@ -66,7 +66,7 @@ static bool is_interface(const char* dev_name, pid_t pid)
 
        if (p < 0) {
                SYSERROR("failed to fork task.");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (p == 0) {
@@ -86,10 +86,10 @@ static bool is_interface(const char* dev_name, pid_t pid)
                /* Iterate through the interfaces */
                for (tempIfAddr = interfaceArray; tempIfAddr != NULL; tempIfAddr = tempIfAddr->ifa_next) {
                        if (strcmp(tempIfAddr->ifa_name, dev_name) == 0) {
-                               exit(0);
+                               exit(EXIT_SUCCESS);
                        }
                }
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        if (wait_for_pid(p) == 0) {
index 646c97f222a584d8bec3e732661dfee21ba64f99..6c9423fae878c35fe149b64456697573dee5f751 100644 (file)
@@ -77,7 +77,7 @@ static void usage(char *cmd)
        fprintf(stderr, "\t -H <hostname>: Set the hostname in the container\n");
        fprintf(stderr, "\t -d           : Daemonize (do not wait for container to exit)\n");
        fprintf(stderr, "\t -M           : reMount default fs inside container (/proc /dev/shm /dev/mqueue)\n");
-       _exit(1);
+       _exit(EXIT_SUCCESS);
 }
 
 static bool lookup_user(const char *optarg, uid_t *uid)
@@ -134,13 +134,13 @@ static int do_start(void *arg)
        if ((flags & CLONE_NEWUTS) && want_hostname)
                if (sethostname(want_hostname, strlen(want_hostname)) < 0) {
                        ERROR("failed to set hostname %s: %s", want_hostname, strerror(errno));
-                       exit(1);
+                       exit(EXIT_FAILURE);
                }
 
        // Setuid is useful even without a new user id space
        if (start_arg->setuid && setuid(uid)) {
                ERROR("failed to set uid %d: %s", uid, strerror(errno));
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        execvp(args[0], args);
@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
                case 'i':
                        if (!(tmpif = malloc(sizeof(*tmpif)))) {
                                perror("malloc");
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        }
                        tmpif->mi_ifname = optarg;
                        tmpif->mi_next = my_iflist;
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
        }
 
        if (daemonize)
-               exit(0);
+               exit(EXIT_SUCCESS);
 
        if (waitpid(pid, &status, 0) < 0) {
                ERROR("failed to wait for '%d'", pid);
index 16dd298714eb592afb9e1c74f3ae225663d1c23f..9905d53b39aa91acf15394dd8285e263772e261f 100644 (file)
@@ -71,7 +71,7 @@ static void usage(const char *name)
        printf("  Note: This program uses newuidmap(2) and newgidmap(2).\n");
        printf("        As such, /etc/subuid and /etc/subgid must grant the\n");
        printf("        calling user permission to use the mapped ranges\n");
-       exit(1);
+       exit(EXIT_SUCCESS);
 }
 
 static void opentty(const char * tty, int which) {