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

index eb3a91fb2593e31cdc4f32f96df5b67c3dc4eb13..efd499b08706cb3d210fcaa1ba031f92f46a7fbb 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
                        ret = parse_cgroup_spec(cgroup_list, optarg, CG_HIER_MAX);
                        if (ret) {
                                err("cgroup controller and path parsing failed\n");
-                               return -1;
+                               exit(EXIT_BADARGS);
                        }
                        cg_specified = 1;
                        break;
@@ -82,14 +82,14 @@ int main(int argc, char *argv[])
                        exit(0);
                default:
                        usage(1, argv[0]);
-                       exit(1);
+                       exit(EXIT_BADARGS);
                }
        }
 
        /* Executable name */
        if (!argv[optind]) {
                usage(1, argv[0]);
-               exit(1);
+               exit(EXIT_BADARGS);
        }
 
        /* Initialize libcg */