From bcfa8a05018b339b9b5609fe975a3a7b29cc0c6e Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 17 Jan 2012 17:03:57 -0500 Subject: [PATCH] Don't start session daemon with --help on the cli Any --help or -h will not spawned anymore a session daemon when used with lttng cli. Signed-off-by: David Goulet --- lttng/lttng.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lttng/lttng.c b/lttng/lttng.c index d0f23579d..45a6fa0be 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -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; } -- 2.34.1