]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/cgxget: use exit code 129 on invalid usage
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Thu, 29 Sep 2022 10:20:41 +0000 (15:50 +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/cgxget.c

index 0d7da5b8efd6d4d17fc65ea064b94856280a6fcb..6aee4fd47c0a986fdec1366a59a8c90bad3805c0 100644 (file)
@@ -337,7 +337,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);
        }
 
        /*
@@ -351,7 +351,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) {
@@ -462,14 +462,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);
@@ -797,7 +797,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();