Don't start session daemon with --help on the cli
authorDavid Goulet <dgoulet@efficios.com>
Tue, 17 Jan 2012 22:03:57 +0000 (17:03 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 17 Jan 2012 22:03:57 +0000 (17:03 -0500)
Any --help or -h will not spawned anymore a session daemon when used
with lttng cli.

Signed-off-by: David Goulet <dgoulet@efficios.com>
lttng/lttng.c

index d0f23579d4af38db63ba9ec2e9f76aaa7155b299..45a6fa0be1f961f84dfe10c74fcd9d8a8d0ec721 100644 (file)
@@ -359,6 +359,23 @@ end:
        return ret;
 }
 
+/*
+ * Check for the "help" option in the argv. If found, return 1 else return 0.
+ */
+static int check_help_command(int argc, char **argv)
+{
+       int i;
+
+       for (i = 0; i < argc; i++) {
+               if ((strncmp(argv[i], "-h", 2) == 0) ||
+                               strncmp(argv[i], "--h", 3)) {
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
 /*
  *  parse_args
  *
@@ -414,7 +431,8 @@ static int parse_args(int argc, char **argv)
        }
 
        /* Spawn session daemon if needed */
-       if (opt_no_sessiond == 0 && (check_sessiond() < 0)) {
+       if (opt_no_sessiond == 0 && check_help_command(argc, argv) == 0 &&
+                       (check_sessiond() < 0)) {
                goto error;
        }
 
This page took 0.027051 seconds and 4 git commands to generate.