X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fview.c;h=793804b4e9b95ad7ddf9d5c3dcfd510d25fe217b;hb=85a68078491446314361d6c8b06e5c5aaeb7a17f;hp=a146a91cf3131765dee43a258b483725e8d967a2;hpb=0c95f5b2ec754e905a0263cafc6e453f451d0ded;p=lttng-tools.git diff --git a/src/bin/lttng/commands/view.c b/src/bin/lttng/commands/view.c index a146a91cf..793804b4e 100644 --- a/src/bin/lttng/commands/view.c +++ b/src/bin/lttng/commands/view.c @@ -48,7 +48,7 @@ static struct poptOption long_options[] = { /* * This is needed for each viewer since we are using execvp(). */ -static const char *babeltrace_opts[] = { "babeltrace", "-n", "all", }; +static const char *babeltrace_opts[] = { "babeltrace" }; //static const char *lttv_gui_opts[] = { "lttv-gui", "-t", }; /* @@ -198,7 +198,6 @@ error: static int spawn_viewer(const char *trace_path) { int ret = 0; - pid_t pid; struct stat status; const char *viewer_bin = NULL; struct viewers *viewer; @@ -211,61 +210,53 @@ static int spawn_viewer(const char *trace_path) goto error; } - pid = fork(); - if (pid == 0) { - switch (viewer->type) { - case VIEWER_BABELTRACE: - if (stat(babeltrace_bin, &status) == 0) { - viewer_bin = babeltrace_bin; - } else { - viewer_bin = viewer->exec_name; - } - argv = alloc_argv_from_local_opts(babeltrace_opts, - ARRAY_SIZE(babeltrace_opts), trace_path); - break; + switch (viewer->type) { + case VIEWER_BABELTRACE: + if (stat(babeltrace_bin, &status) == 0) { + viewer_bin = babeltrace_bin; + } else { + viewer_bin = viewer->exec_name; + } + argv = alloc_argv_from_local_opts(babeltrace_opts, + ARRAY_SIZE(babeltrace_opts), trace_path); + break; #if 0 - case VIEWER_LTTV_GUI: - if (stat(lttv_gui_bin, &status) == 0) { - viewer_bin = lttv_gui_bin; - } else { - viewer_bin = viewer->exec_name; - } - argv = alloc_argv_from_local_opts(lttv_gui_opts, - ARRAY_SIZE(lttv_gui_opts), trace_path); - break; + case VIEWER_LTTV_GUI: + if (stat(lttv_gui_bin, &status) == 0) { + viewer_bin = lttv_gui_bin; + } else { + viewer_bin = viewer->exec_name; + } + argv = alloc_argv_from_local_opts(lttv_gui_opts, + ARRAY_SIZE(lttv_gui_opts), trace_path); + break; #endif - case VIEWER_USER_DEFINED: - argv = alloc_argv_from_user_opts(opt_viewer, trace_path); - if (argv) { - viewer_bin = argv[0]; - } - break; - default: - viewer_bin = viewers[VIEWER_BABELTRACE].exec_name; - argv = alloc_argv_from_local_opts(babeltrace_opts, - ARRAY_SIZE(babeltrace_opts), trace_path); - break; + case VIEWER_USER_DEFINED: + argv = alloc_argv_from_user_opts(opt_viewer, trace_path); + if (argv) { + viewer_bin = argv[0]; } + break; + default: + viewer_bin = viewers[VIEWER_BABELTRACE].exec_name; + argv = alloc_argv_from_local_opts(babeltrace_opts, + ARRAY_SIZE(babeltrace_opts), trace_path); + break; + } - if (argv == NULL) { - ret = CMD_FATAL; - goto error; - } + if (argv == NULL) { + ret = CMD_FATAL; + goto error; + } - DBG("Using %s viewer", viewer_bin); + DBG("Using %s viewer", viewer_bin); - ret = execvp(viewer_bin, argv); - if (ret) { - PERROR("exec: %s", viewer_bin); - free(argv); - ret = CMD_FATAL; - goto error; - } - } else if (pid > 0) { - ret = CMD_SUCCESS; - } else { - PERROR("Fork trace viewer"); + ret = execvp(viewer_bin, argv); + if (ret) { + PERROR("exec: %s", viewer_bin); + free(argv); ret = CMD_FATAL; + goto error; } error: @@ -288,9 +279,11 @@ static int view_trace(void) if (getuid() != 0) { if (getuid() != geteuid()) { ERR("UID does not match effective UID."); + ret = CMD_ERROR; goto error; } else if (getgid() != getegid()) { ERR("GID does not match effective GID."); + ret = CMD_ERROR; goto error; } } @@ -327,6 +320,7 @@ static int view_trace(void) if (!found) { MSG("Session name %s not found", session_name); + ret = CMD_ERROR; goto free_sessions; }