Cleanup: consumerd: use PERROR rather than perror
[lttng-tools.git] / src / bin / lttng-consumerd / lttng-consumerd.c
index e226ebc69e973eb34faa74d7a1be56ab7c3ab090..d2c3ed4ed605174aa2d0f4e0b12afc0c39b0dfee 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <fcntl.h>
 #include <getopt.h>
 #include <grp.h>
@@ -52,8 +53,6 @@
 #include "lttng-consumerd.h"
 #include "health-consumerd.h"
 
-/* TODO : support UST (all direct kernel-ctl accesses). */
-
 /* threads (channel handling, poll, metadata, sessiond) */
 
 static pthread_t channel_thread, data_thread, metadata_thread,
@@ -65,6 +64,8 @@ static int sigintcount = 0;
 /* Argument variables */
 int lttng_opt_quiet;    /* not static in error.h */
 int lttng_opt_verbose;  /* not static in error.h */
+int lttng_opt_mi;       /* not static in error.h */
+
 static int opt_daemon;
 static const char *progname;
 static char command_sock_path[PATH_MAX]; /* Global command socket path */
@@ -121,7 +122,7 @@ static int set_signal_handler(void)
        sigset_t sigset;
 
        if ((ret = sigemptyset(&sigset)) < 0) {
-               perror("sigemptyset");
+               PERROR("sigemptyset");
                return ret;
        }
 
@@ -129,17 +130,17 @@ static int set_signal_handler(void)
        sa.sa_mask = sigset;
        sa.sa_flags = 0;
        if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
-               perror("sigaction");
+               PERROR("sigaction");
                return ret;
        }
 
        if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
-               perror("sigaction");
+               PERROR("sigaction");
                return ret;
        }
 
        if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) {
-               perror("sigaction");
+               PERROR("sigaction");
                return ret;
        }
 
@@ -183,9 +184,9 @@ static void usage(FILE *fp)
 /*
  * daemon argument parsing
  */
-static void parse_args(int argc, char **argv)
+static int parse_args(int argc, char **argv)
 {
-       int c;
+       int c, ret = 0;
 
        static struct option long_options[] = {
                { "consumerd-cmd-sock", 1, 0, 'c' },
@@ -215,6 +216,8 @@ static void parse_args(int argc, char **argv)
                        fprintf(stderr, "option %s", long_options[option_index].name);
                        if (optarg) {
                                fprintf(stderr, " with arg %s\n", optarg);
+                               ret = -1;
+                               goto end;
                        }
                        break;
                case 'c':
@@ -257,9 +260,12 @@ static void parse_args(int argc, char **argv)
 #endif
                default:
                        usage(stderr);
-                       exit(EXIT_FAILURE);
+                       ret = -1;
+                       goto end;
                }
        }
+end:
+       return ret;
 }
 
 /*
@@ -520,15 +526,11 @@ health_error:
 error_health_pipe:
        if (!ret) {
                ret = EXIT_SUCCESS;
-               lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_EXIT_SUCCESS);
                goto end;
        }
 
 error:
        ret = EXIT_FAILURE;
-       if (ctx) {
-               lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_EXIT_FAILURE);
-       }
 
 end:
        lttng_consumer_destroy(ctx);
This page took 0.027426 seconds and 5 git commands to generate.