lttng-crash: use `spawn_viewer()` to launch trace viewer
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 3 Apr 2020 18:57:55 +0000 (14:57 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 Apr 2020 22:33:19 +0000 (18:33 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I59f8d6c1189b3b3b4cfd0704ff2c8eb22e6df44f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-crash/lttng-crash.c

index 262cd7cc0d7af67dd4b38b19cc3f6d7b7af79b11..8f94544ba54794f1dbbed0fecca70cc5e44b2028 100644 (file)
 #include <version.h>
 #include <lttng/lttng.h>
 #include <common/common.h>
+#include <common/spawn-viewer.h>
 #include <common/utils.h>
 
-#define DEFAULT_VIEWER "babeltrace"
-
 #define COPY_BUFLEN            4096
 #define RB_CRASH_DUMP_ABI_LEN  32
 
@@ -295,10 +294,6 @@ static int parse_args(int argc, char **argv)
                }
        }
 
-       if (!opt_viewer_path) {
-               opt_viewer_path = (char *) DEFAULT_VIEWER;
-       }
-
        /* No leftovers, or more than one input path, print usage and quit */
        if (argc - optind != 1) {
                ERR("Command-line error: Specify exactly one input path");
@@ -1181,7 +1176,7 @@ end_no_closedir:
 }
 
 static
-int view_trace(const char *viewer_path, const char *trace_path)
+int view_trace(const char *trace_path, char *viewer_path)
 {
        pid_t pid;
 
@@ -1202,13 +1197,12 @@ int view_trace(const char *viewer_path, const char *trace_path)
                /* Child */
                int ret;
 
-               ret = execlp(viewer_path, viewer_path,
-                       trace_path, (char *) NULL);
+               ret = spawn_viewer(trace_path, viewer_path, false);
                if (ret) {
-                       PERROR("execlp");
                        exit(EXIT_FAILURE);
                }
-               exit(EXIT_SUCCESS);     /* Never reached */
+               /* Never reached */
+               exit(EXIT_SUCCESS);
        }
        return 0;
 }
@@ -1260,7 +1254,7 @@ int main(int argc, char *argv[])
        }
        if (!opt_output_path) {
                /* View trace */
-               ret = view_trace(opt_viewer_path, output_path);
+               ret = view_trace(output_path, opt_viewer_path);
                if (ret) {
                        has_warning = true;
                }
This page took 0.034254 seconds and 4 git commands to generate.