#include "lttng-consumerd.h"
-/* TODO : support UST (all direct kernctl accesses). */
+/* TODO : support UST (all direct kern-ctl accesses). */
/* the two threads (receive fd and poll) */
static pthread_t threads[2];
-/* to count the number of time the user pressed ctrl+c */
+/* to count the number of times the user pressed ctrl+c */
static int sigintcount = 0;
/* Argument variables */
}
/*
- * usage function on stderr
+ * Usage function on stream file.
*/
-static void usage(void)
+static void usage(FILE *fp)
{
- fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname);
- fprintf(stderr, " -h, --help "
+ fprintf(fp, "Usage: %s OPTIONS\n\nOptions:\n", progname);
+ fprintf(fp, " -h, --help "
"Display this usage.\n");
- fprintf(stderr, " -c, --consumerd-cmd-sock PATH "
+ fprintf(fp, " -c, --consumerd-cmd-sock PATH "
"Specify path for the command socket\n");
- fprintf(stderr, " -e, --consumerd-err-sock PATH "
+ fprintf(fp, " -e, --consumerd-err-sock PATH "
"Specify path for the error socket\n");
- fprintf(stderr, " -d, --daemonize "
+ fprintf(fp, " -d, --daemonize "
"Start as a daemon.\n");
- fprintf(stderr, " -q, --quiet "
+ fprintf(fp, " -q, --quiet "
"No output at all.\n");
- fprintf(stderr, " -v, --verbose "
+ fprintf(fp, " -v, --verbose "
"Verbose mode. Activate DBG() macro.\n");
- fprintf(stderr, " -V, --version "
+ fprintf(fp, " -V, --version "
"Show version number.\n");
- fprintf(stderr, " -k, --kernel "
+ fprintf(fp, " -k, --kernel "
"Consumer kernel buffers (default).\n");
- fprintf(stderr, " -u, --ust "
+ fprintf(fp, " -u, --ust "
"Consumer UST buffers.%s\n",
#ifdef HAVE_LIBLTTNG_UST_CTL
""
opt_daemon = 1;
break;
case 'h':
- usage();
- exit(EXIT_FAILURE);
+ usage(stdout);
+ exit(EXIT_SUCCESS);
case 'q':
opt_quiet = 1;
break;
break;
#endif
default:
- usage();
+ usage(stderr);
exit(EXIT_FAILURE);
}
}
ret = lttcomm_connect_unix_sock(error_sock_path);
/* not a fatal error, but all communication with lttng-sessiond will fail */
if (ret < 0) {
- WARN("Cannot connect to error socket, is lttng-sessiond started ?");
+ WARN("Cannot connect to error socket (is lttng-sessiond started ?)");
}
lttng_consumer_set_error_sock(ctx, ret);
if (opt_sessiond_path != NULL) {
ret = access(opt_sessiond_path, F_OK | X_OK);
if (ret < 0) {
- ERR("No such file: %s", opt_sessiond_path);
+ ERR("No such file or access denied: %s", opt_sessiond_path);
goto end;
}
pathname = opt_sessiond_path;
ret = spawn_sessiond(pathname);
free(alloc_pathname);
if (ret < 0) {
- ERR("Problem occurs when starting %s", pathname);
+ ERR("Problem occurred when starting %s", pathname);
goto end;
}
}
for (i = 0; i < argc; i++) {
if ((strncmp(argv[i], "-h", sizeof("-h")) == 0) ||
strncmp(argv[i], "--h", sizeof("--h")) == 0 ||
- strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0) {
+ strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0 ||
+ strncmp(argv[i], "--list-commands", sizeof("--list-commands")) == 0) {
return 1;
}
}
}
/*
- * parse_args
+ * Parse command line arguments.
*
- * Parse command line arguments.
- * Return 0 if OK, else -1
+ * Return 0 if OK, else -1
*/
static int parse_args(int argc, char **argv)
{
while ((opt = getopt_long(argc, argv, "+hnvqg:", long_options, NULL)) != -1) {
switch (opt) {
case 'h':
- usage(stderr);
- goto error;
+ usage(stdout);
+ goto end;
case 'v':
opt_verbose += 1;
break;
case OPT_DUMP_OPTIONS:
list_options(stdout);
ret = 0;
- goto error;
+ goto end;
case OPT_DUMP_COMMANDS:
list_commands(stdout);
ret = 0;
- goto error;
+ goto end;
default:
usage(stderr);
goto error;
goto error;
}
+end:
return 0;
error: