]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
waitpid: detect exlusive options with standard mechanism
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 3 Mar 2023 15:54:26 +0000 (15:54 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Fri, 3 Mar 2023 16:11:23 +0000 (16:11 +0000)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
misc-utils/waitpid.c

index 871a36949e917f3ea91bc4c87c460c5957def236..b01a2f01310b7645a4ca883a99d21c3e243b1c0f 100644 (file)
@@ -35,6 +35,7 @@
 #include "strutils.h"
 #include "exitcodes.h"
 #include "timeutils.h"
+#include "optutils.h"
 
 #define EXIT_TIMEOUT_EXPIRED 3
 
@@ -184,8 +185,16 @@ static int parse_options(int argc, char **argv)
                { "help",    no_argument,       NULL, 'h' },
                { 0 }
        };
+       static const ul_excl_t excl[] = {       /* rows and cols in ASCII order */
+               { 'c', 'e' },
+               { 0 }
+       };
+       int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
 
        while ((c = getopt_long (argc, argv, "vVht:c:e", longopts, NULL)) != -1) {
+
+               err_exclusive_options(c, longopts, excl, excl_st);
+
                switch (c) {
                case 'v':
                        verbose = true;
@@ -210,10 +219,6 @@ static int parse_options(int argc, char **argv)
                }
        }
 
-       if (allow_exited && count)
-               errx(EXIT_FAILURE,
-                    _("-e/--exited and -c/--count are incompatible"));
-
        return optind;
 }