]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/cgget: use exit code 129 on invalid usage
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Thu, 29 Sep 2022 10:19:55 +0000 (15:49 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 30 Sep 2022 14:34:55 +0000 (08:34 -0600)
The exit code 1 refers to general error and using -1 wraps to
255, both codes do not signify bad arguments. Let's use exit code 129
(EXIT_BADARGS) for hinting to the users about invalid usage.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/cgget.c

index 33928c37333f78a6aa55167f267b5520e3f31cb3..bf3e0aadc880de5b3493df68420e806c02cd2f58 100644 (file)
@@ -321,7 +321,7 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
         */
        if (argv[optind] == NULL && first_cg_is_dummy) {
                usage(1, argv[0]);
-               exit(-1);
+               exit(EXIT_BADARGS);
        }
 
        /*
@@ -336,7 +336,7 @@ static int parse_opt_args(int argc, char *argv[], struct cgroup **cg_list[],
        if (argv[optind] != NULL && (*cg_list_len) > 0 &&
            strcmp((*cg_list)[0]->name, "") != 0) {
                usage(1, argv[0]);
-               exit(-1);
+               exit(EXIT_BADARGS);
        }
 
        while (argv[optind] != NULL) {
@@ -436,14 +436,14 @@ static int parse_opts(int argc, char *argv[], struct cgroup **cg_list[], int * c
                        break;
                default:
                        usage(1, argv[0]);
-                       exit(1);
+                       exit(EXIT_BADARGS);
                }
        }
 
        /* Don't allow '-r' and ('-g' or '-a') */
        if (fill_controller && do_not_fill_controller) {
                usage(1, argv[0]);
-               exit(1);
+               exit(EXIT_BADARGS);
        }
 
        ret = parse_opt_args(argc, argv, cg_list, cg_list_len, first_cgroup_is_dummy);
@@ -725,7 +725,7 @@ int main(int argc, char *argv[])
        /* No parameter on input? */
        if (argc < 2) {
                usage(1, argv[0]);
-               return 1;
+               exit(EXIT_BADARGS);
        }
 
        ret = cgroup_init();