]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
commandhelper: Consolidate argument parsing
authorTim Wiederhake <twiederh@redhat.com>
Mon, 1 Feb 2021 11:27:49 +0000 (12:27 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Feb 2021 14:00:53 +0000 (15:00 +0100)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tests/commandhelper.c

index 1ee697498cea743be71d15f61b01c5b6dfd3b4c0..62e1b98c60849f36b40b6da9173d9f6b2be2ff63 100644 (file)
@@ -66,6 +66,7 @@ int main(int argc, char **argv) {
     size_t buflen[3] = {0, 0, 0};
     char c;
     bool daemonize_check = false;
+    bool close_stdin = false;
     size_t daemonize_retries = 3;
     char buf[1024];
     ssize_t got;
@@ -82,6 +83,8 @@ int main(int argc, char **argv) {
             goto cleanup;
         } else if (STREQ(argv[i], "--check-daemonize")) {
             daemonize_check = true;
+        } else if (STREQ(argv[i], "--close-stdin")) {
+            close_stdin = true;
         }
     }
 
@@ -149,7 +152,7 @@ int main(int argc, char **argv) {
 
     fprintf(log, "UMASK:%04o\n", umask(0));
 
-    if (argc > 1 && STREQ(argv[1], "--close-stdin")) {
+    if (close_stdin) {
         if (freopen("/dev/null", "r", stdin) != stdin)
             goto cleanup;
         usleep(100*1000);