Fix segfault when stoping a kernel session that does not exist
[lttng-tools.git] / lttng / lttng.c
CommitLineData
826d496d
MD
1/*
2 * Copyright (c) 2011 David Goulet <david.goulet@polymtl.ca>
fac6795d
DG
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
fac6795d
DG
17 */
18
19#define _GNU_SOURCE
20#include <errno.h>
21#include <fcntl.h>
22#include <getopt.h>
23#include <grp.h>
24#include <limits.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <sys/stat.h>
29#include <sys/types.h>
30#include <sys/wait.h>
31#include <unistd.h>
32
5b97ec60 33#include <lttng/lttng.h>
fac6795d
DG
34
35#include "lttng.h"
36#include "lttngerr.h"
37
38/* Variables */
39static char *progname;
96243366 40static char *session_name;
96243366 41static uuid_t current_uuid;
894be886
DG
42static int auto_session;
43static int auto_trace;
fac6795d
DG
44
45/* Prototypes */
46static int process_client_opt(void);
47static int process_opt_list_apps(void);
57167058 48static int process_opt_list_sessions(void);
1657e9bb 49static int process_opt_list_traces(void);
aaf97519 50static int process_opt_create_session(void);
894be886
DG
51static int process_kernel_create_trace(void);
52static int process_opt_kernel_event(void);
8c0faa1d 53static int process_kernel_start_trace(void);
96243366 54static int set_session_uuid(void);
5b8719f5
DG
55static void sighandler(int sig);
56static int set_signal_handler(void);
8548ff30 57static int validate_options(void);
47b74d63 58static char *get_cmdline_by_pid(pid_t pid);
96243366 59static void set_opt_session_info(void);
fac6795d
DG
60
61/*
62 * start_client
63 *
64 * Process client request from the command line
65 * options. Every tracing action is done by the
66 * liblttngctl API.
67 */
68static int process_client_opt(void)
69{
70 int ret;
96243366
DG
71
72 set_opt_session_info();
fac6795d 73
fac6795d
DG
74 if (opt_list_apps) {
75 ret = process_opt_list_apps();
76 if (ret < 0) {
fac6795d
DG
77 goto end;
78 }
894be886 79 goto error;
fac6795d
DG
80 }
81
57167058
DG
82 if (opt_list_session) {
83 ret = process_opt_list_sessions();
84 if (ret < 0) {
85 goto end;
86 }
894be886 87 goto error;
57167058
DG
88 }
89
894be886
DG
90 /* Session creation or auto session set on */
91 if (auto_session || opt_create_session) {
92 DBG("Creating a new session");
93 ret = process_opt_create_session();
1657e9bb
DG
94 if (ret < 0) {
95 goto end;
96 }
97 }
98
894be886
DG
99 ret = set_session_uuid();
100 if (ret < 0) {
101 ERR("Session %s not found", opt_session_name);
102 goto error;
103 }
aaf97519 104
894be886
DG
105 if (opt_destroy_session) {
106 ret = lttng_destroy_session(&current_uuid);
8028d920 107 if (ret < 0) {
894be886 108 goto end;
8028d920 109 }
894be886 110 MSG("Session %s destroyed.", opt_session_name);
8028d920
DG
111 }
112
96243366
DG
113 if (opt_list_traces) {
114 ret = process_opt_list_traces();
7442b2ba 115 if (ret < 0) {
96243366 116 goto end;
7442b2ba 117 }
e8be5f4f
DG
118 }
119
96243366
DG
120 /*
121 * Action on traces (kernel or/and userspace).
122 */
894be886 123
ad874cce 124 if (opt_trace_kernel) {
894be886
DG
125 if (auto_trace || opt_create_trace) {
126 DBG("Creating a kernel trace");
127 ret = process_kernel_create_trace();
128 if (ret < 0) {
129 goto end;
130 }
131 }
132
133 if (opt_event_list != NULL) {
134 ret = process_opt_kernel_event();
f34daff7
DG
135 if (ret < 0) {
136 goto end;
137 }
894be886
DG
138 } else {
139 // Enable all events
140 }
8c0faa1d
DG
141
142 if (auto_trace || opt_start_trace) {
143 DBG("Starting kernel tracing");
144 ret = process_kernel_start_trace();
145 if (ret < 0) {
146 goto end;
147 }
148 }
149
150 if (opt_stop_trace) {
151 DBG("Stopping kernel tracing");
152 ret = lttng_kernel_stop_tracing();
153 if (ret < 0) {
154 goto end;
155 }
156 }
df0da139
DG
157 }
158
ad874cce 159 if (opt_trace_pid != 0) {
894be886 160 if (auto_trace || opt_create_trace) {
ad874cce
DG
161 DBG("Create a userspace trace for pid %d", opt_trace_pid);
162 ret = lttng_ust_create_trace(opt_trace_pid);
163 if (ret < 0) {
164 goto end;
165 }
894be886 166 MSG("Trace created successfully!");
ce3d728c 167 }
ce3d728c 168
894be886 169 if (auto_trace || opt_start_trace) {
ad874cce
DG
170 DBG("Start trace for pid %d", opt_trace_pid);
171 ret = lttng_ust_start_trace(opt_trace_pid);
172 if (ret < 0) {
173 goto end;
174 }
175 MSG("Trace started successfully!");
176 } else if (opt_stop_trace) {
177 DBG("Stop trace for pid %d", opt_trace_pid);
178 ret = lttng_ust_stop_trace(opt_trace_pid);
179 if (ret < 0) {
180 goto end;
181 }
182 MSG("Trace stopped successfully!");
520ff687 183 }
ad874cce 184
520ff687
DG
185 }
186
fac6795d
DG
187 return 0;
188
189end:
ebafd2a5 190 ERR("%s", lttng_get_readable_code(ret));
5e16da05 191error: /* fall through */
7442b2ba
DG
192 return ret;
193}
194
8c0faa1d
DG
195/*
196 * process_kernel_start_trace
197 *
198 * Start a kernel trace.
199 */
200static int process_kernel_start_trace(void)
201{
202 int ret;
203
204 ret = lttng_kernel_create_stream();
205 if (ret < 0) {
206 goto error;
207 }
208
209 ret = lttng_kernel_start_tracing();
210 if (ret < 0) {
211 goto error;
212 }
213
214 MSG("Kernel tracing started");
215
216 return 0;
217
218error:
219 return ret;
220}
221
7442b2ba 222/*
894be886 223 * process_kernel_create_trace
96243366 224 *
894be886 225 * Create a kernel trace.
96243366 226 */
894be886 227static int process_kernel_create_trace(void)
96243366 228{
20fe2104
DG
229 int ret;
230
231 /* Setup kernel session */
232 ret = lttng_kernel_create_session();
233 if (ret < 0) {
234 goto error;
235 }
236
237 /* Create an empty channel (with no event) */
238 ret = lttng_kernel_create_channel();
239 if (ret < 0) {
240 goto error;
a5c5a2bd
DG
241 }
242
243 /* Opening metadata for session */
244 ret = lttng_kernel_open_metadata();
245 if (ret < 0) {
246 goto error;
20fe2104
DG
247 }
248
894be886 249 return 0;
20fe2104
DG
250
251error:
252 return ret;
894be886 253}
96243366 254
894be886
DG
255/*
256 * process_kernel_event
257 *
258 * Enable kernel event from the command line list given.
259 */
260static int process_opt_kernel_event(void)
261{
262 int ret;
263 char *event_name;
96243366 264
894be886
DG
265 event_name = strtok(opt_event_list, ",");
266 while (event_name != NULL) {
267 DBG("Enabling kernel event %s", event_name);
268 ret = lttng_kernel_enable_event(event_name);
269 if (ret < 0) {
270 ERR("%s %s", lttng_get_readable_code(ret), event_name);
271 } else {
272 MSG("Kernel event %s enabled.", event_name);
96243366 273 }
894be886
DG
274 /* Next event */
275 event_name = strtok(NULL, ",");
96243366
DG
276 }
277
894be886 278 return 0;
96243366
DG
279}
280
281/*
894be886 282 * set_opt_session_info
96243366 283 *
894be886
DG
284 * Setup session_name, current_uuid, short_str_uuid and
285 * long_str_uuid using the command line options.
96243366 286 */
894be886 287static void set_opt_session_info(void)
96243366 288{
894be886
DG
289 if (opt_session_name != NULL) {
290 session_name = strndup(opt_session_name, NAME_MAX);
291 DBG("Session name set to %s", session_name);
292 }
96243366
DG
293}
294
295/*
296 * set_session_uuid
7442b2ba 297 *
894be886
DG
298 * Set current session uuid to the current flow of command(s) using the
299 * session_name.
7442b2ba 300 */
96243366 301static int set_session_uuid(void)
7442b2ba 302{
894be886 303 int ret, count, i, found = 0;
7442b2ba
DG
304 struct lttng_session *sessions;
305
96243366
DG
306 if (!uuid_is_null(current_uuid)) {
307 lttng_set_current_session_uuid(&current_uuid);
308 goto end;
309 }
310
7442b2ba
DG
311 count = lttng_list_sessions(&sessions);
312 if (count < 0) {
313 ret = count;
314 goto error;
315 }
316
317 for (i = 0; i < count; i++) {
894be886 318 if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
96243366 319 lttng_set_current_session_uuid(&sessions[i].uuid);
894be886
DG
320 uuid_copy(current_uuid, sessions[i].uuid);
321 found = 1;
7442b2ba
DG
322 break;
323 }
324 }
325
326 free(sessions);
327
894be886
DG
328 if (!found) {
329 return -1;
330 }
331
96243366 332end:
894be886 333 DBG("Session UUID set");
7442b2ba
DG
334 return 0;
335
336error:
337 return ret;
fac6795d
DG
338}
339
1657e9bb
DG
340/*
341 * process_opt_list_traces
342 *
343 * Get list of all traces for a specific session uuid.
344 */
345static int process_opt_list_traces(void)
346{
347 int ret, i;
1657e9bb
DG
348 struct lttng_trace *traces;
349
96243366 350 ret = lttng_list_traces(&current_uuid, &traces);
894be886 351 DBG("Number of traces to list %d", ret);
1657e9bb
DG
352 if (ret < 0) {
353 goto error;
354 }
355
894be886
DG
356 /* No traces */
357 if (ret == 0) {
358 MSG("No traces found.");
359 goto error;
360 }
361
1657e9bb
DG
362 MSG("Userspace traces:");
363 for (i = 0; i < ret; i++) {
364 if (traces[i].type == USERSPACE) {
47b74d63
DG
365 MSG("\t%d) %s (pid: %d): %s",
366 i, traces[i].name, traces[i].pid,
367 get_cmdline_by_pid(traces[i].pid));
1657e9bb
DG
368 } else {
369 break;
370 }
371 }
372
373 MSG("Kernel traces:");
374 for (;i < ret; i++) {
375 if (traces[i].type == KERNEL) {
376 MSG("\t%d) %s", i, traces[i].name);
377 }
378 }
379
380 free(traces);
381
382error:
383 return ret;
384}
385
aaf97519
DG
386/*
387 * process_opt_create_session
388 *
389 * Create a new session using the name pass
390 * to the command line.
391 */
392static int process_opt_create_session(void)
393{
394 int ret;
96243366
DG
395 char name[NAME_MAX];
396 time_t rawtime;
397 struct tm *timeinfo;
398
894be886
DG
399 /* Auto session name creation */
400 if (opt_session_name == NULL) {
96243366
DG
401 time(&rawtime);
402 timeinfo = localtime(&rawtime);
894be886 403 strftime(name, sizeof(name), "auto-%Y%m%d-%H%M%S", timeinfo);
96243366 404 session_name = strndup(name, sizeof(name));
894be886 405 DBG("Auto session name set to %s", session_name);
96243366 406 }
aaf97519 407
894be886 408 ret = lttng_create_session(session_name);
aaf97519
DG
409 if (ret < 0) {
410 goto error;
411 }
412
894be886 413 MSG("Session created: %s", session_name);
aaf97519
DG
414
415error:
416 return ret;
417}
418
57167058
DG
419/*
420 * process_opt_list_sessions
421 *
422 * Get the list of available sessions from
423 * the session daemon and print it to user.
424 */
425static int process_opt_list_sessions(void)
426{
427 int ret, count, i;
894be886 428 struct lttng_session *sessions;
57167058 429
894be886 430 count = lttng_list_sessions(&sessions);
7442b2ba 431 DBG("Session count %d", count);
57167058
DG
432 if (count < 0) {
433 ret = count;
434 goto error;
435 }
436
7442b2ba 437 MSG("Available sessions (UUIDs):");
57167058 438 for (i = 0; i < count; i++) {
894be886 439 MSG(" %d) %s", i+1, sessions[i].name);
57167058
DG
440 }
441
894be886 442 free(sessions);
7442b2ba 443 MSG("\nTo select a session, use -s, --session UUID.");
57167058
DG
444
445 return 0;
446
447error:
448 return ret;
449}
450
fac6795d
DG
451/*
452 * process_opt_list_apps
453 *
454 * Get the UST traceable pid list and print
455 * them to the user.
456 */
457static int process_opt_list_apps(void)
458{
e8f07c63 459 int i, ret, count;
fac6795d 460 pid_t *pids;
1c9f7941 461 char *cmdline;
fac6795d 462
e8f07c63
DG
463 count = lttng_ust_list_apps(&pids);
464 if (count < 0) {
465 ret = count;
fac6795d
DG
466 goto error;
467 }
468
469 MSG("LTTng UST traceable application [name (pid)]:");
e8f07c63 470 for (i=0; i < count; i++) {
47b74d63
DG
471 cmdline = get_cmdline_by_pid(pids[i]);
472 if (cmdline == NULL) {
e8f07c63 473 MSG("\t(not running) (%d)", pids[i]);
fac6795d
DG
474 continue;
475 }
fac6795d 476 MSG("\t%s (%d)", cmdline, pids[i]);
1c9f7941 477 free(cmdline);
fac6795d
DG
478 }
479
e065084a
DG
480 /* Allocated by lttng_ust_list_apps() */
481 free(pids);
482
fac6795d
DG
483 return 0;
484
485error:
486 return ret;
487}
488
1c9f7941
DG
489/*
490 * get_cmdline_by_pid
491 *
47b74d63 492 * Get command line from /proc for a specific pid.
1c9f7941 493 *
47b74d63
DG
494 * On success, return an allocated string pointer pointing to
495 * the proc cmdline.
496 * On error, return NULL.
1c9f7941 497 */
47b74d63 498static char *get_cmdline_by_pid(pid_t pid)
1c9f7941
DG
499{
500 int ret;
501 FILE *fp;
47b74d63 502 char *cmdline = NULL;
1c9f7941
DG
503 char path[24]; /* Can't go bigger than /proc/65535/cmdline */
504
505 snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
506 fp = fopen(path, "r");
507 if (fp == NULL) {
47b74d63 508 goto end;
1c9f7941
DG
509 }
510
511 /* Caller must free() *cmdline */
47b74d63
DG
512 cmdline = malloc(PATH_MAX);
513 ret = fread(cmdline, 1, PATH_MAX, fp);
1c9f7941
DG
514 fclose(fp);
515
47b74d63
DG
516end:
517 return cmdline;
1c9f7941
DG
518}
519
8548ff30
DG
520/*
521 * validate_options
522 *
894be886
DG
523 * Make sure that all options passed to the command line are compatible with
524 * each others.
8548ff30
DG
525 *
526 * On error, return -1
527 * On success, return 0
528 */
529static int validate_options(void)
530{
894be886
DG
531 /* If listing options, jump validation */
532 if (opt_list_apps || opt_list_session) {
533 goto end;
534 }
ad874cce
DG
535 /* Conflicting command */
536 if (opt_start_trace && opt_stop_trace) {
537 ERR("Can't use --start and --stop together.");
538 goto error;
ad874cce 539 /* If no PID specified and trace_kernel is off */
894be886
DG
540 } else if ((opt_trace_pid == 0 && !opt_trace_kernel) &&
541 (opt_create_trace || opt_start_trace || opt_stop_trace || opt_destroy_trace)) {
542 ERR("Please specify for which tracer (-k or -p PID).");
96243366 543 goto error;
894be886
DG
544 /* List traces, we need a session name */
545 } else if (opt_list_traces && opt_session_name == NULL) {
96243366
DG
546 ERR("Can't use -t without -s, --session option.");
547 goto error;
894be886
DG
548 /* Can't set event for both kernel and userspace at the same time */
549 } else if (opt_event_list != NULL && (opt_trace_kernel && opt_trace_pid)) {
550 ERR("Please don't use --event for both kernel and userspace.\nOne at a time to enable events.");
551 goto error;
552 /* Don't need a trace name for kernel tracig */
553 } else if (opt_trace_name != NULL && opt_trace_kernel) {
554 ERR("For action on a kernel trace, please don't specify a trace name.");
555 goto error;
556 } else if (opt_destroy_trace && opt_session_name == NULL) {
557 ERR("Please specify a session in order to destroy a trace");
558 goto error;
559 } else if (opt_create_trace || opt_destroy_trace) {
560 /* Both kernel and user-space are denied for these options */
561 if (opt_trace_pid != 0 && opt_trace_kernel) {
562 ERR("Kernel and user-space trace creation and destruction can't be used together.");
563 goto error;
564 /* Need a trace name for user-space tracing */
565 } else if (opt_trace_name == NULL && opt_trace_pid != 0) {
566 ERR("Please specify a trace name for user-space tracing");
567 goto error;
568 }
569 } else if (opt_stop_trace && opt_trace_pid != 0 && opt_trace_name == NULL) {
570 ERR("Please specify a trace name for user-space tracing");
571 goto error;
7442b2ba
DG
572 }
573
894be886 574 /* If start trace, auto start tracing */
f34daff7 575 if (opt_start_trace || opt_event_list != NULL) {
894be886
DG
576 DBG("Requesting auto tracing");
577 auto_trace = 1;
578 }
579
580 /* If no session, auto create one */
581 if (opt_session_name == NULL) {
582 DBG("Requesting an auto session creation");
583 auto_session = 1;
584 }
585
586end:
8548ff30
DG
587 return 0;
588
589error:
590 return -1;
591}
592
5b8719f5
DG
593/*
594 * spawn_sessiond
595 *
596 * Spawn a session daemon by forking and execv.
597 */
598static int spawn_sessiond(char *pathname)
599{
600 int ret = 0;
601 pid_t pid;
602
603 MSG("Spawning session daemon");
604 pid = fork();
605 if (pid == 0) {
5e16da05
MD
606 /*
607 * Spawn session daemon and tell
5b8719f5
DG
608 * it to signal us when ready.
609 */
5e16da05
MD
610 execlp(pathname, "ltt-sessiond", "--sig-parent", "--quiet", NULL);
611 /* execlp only returns if error happened */
612 if (errno == ENOENT) {
613 ERR("No session daemon found. Use --sessiond-path.");
614 } else {
615 perror("execlp");
5b8719f5 616 }
5e16da05
MD
617 kill(getppid(), SIGTERM); /* unpause parent */
618 exit(EXIT_FAILURE);
5b8719f5
DG
619 } else if (pid > 0) {
620 /* Wait for ltt-sessiond to start */
621 pause();
622 goto end;
623 } else {
624 perror("fork");
625 ret = -1;
626 goto end;
627 }
628
629end:
630 return ret;
631}
632
fac6795d
DG
633/*
634 * check_ltt_sessiond
635 *
636 * Check if the session daemon is available using
5b8719f5
DG
637 * the liblttngctl API for the check. If not, try to
638 * spawn a daemon.
fac6795d
DG
639 */
640static int check_ltt_sessiond(void)
641{
642 int ret;
5e16da05 643 char *pathname = NULL, *alloc_pathname = NULL;
fac6795d
DG
644
645 ret = lttng_check_session_daemon();
646 if (ret < 0) {
5b8719f5
DG
647 /* Try command line option path */
648 if (opt_sessiond_path != NULL) {
649 ret = access(opt_sessiond_path, F_OK | X_OK);
650 if (ret < 0) {
651 ERR("No such file: %s", opt_sessiond_path);
652 goto end;
653 }
654 pathname = opt_sessiond_path;
655 } else {
656 /* Try LTTNG_SESSIOND_PATH env variable */
e8f07c63 657 pathname = getenv(LTTNG_SESSIOND_PATH_ENV);
5b8719f5
DG
658 }
659
660 /* Let's rock and roll */
661 if (pathname == NULL) {
5e16da05 662 ret = asprintf(&alloc_pathname, "ltt-sessiond");
5b8719f5
DG
663 if (ret < 0) {
664 goto end;
665 }
5e16da05 666 pathname = alloc_pathname;
5b8719f5
DG
667 }
668
669 ret = spawn_sessiond(pathname);
5e16da05 670 free(alloc_pathname);
5b8719f5
DG
671 if (ret < 0) {
672 ERR("Problem occurs when starting %s", pathname);
673 goto end;
674 }
fac6795d
DG
675 }
676
5b8719f5 677end:
fac6795d
DG
678 return ret;
679}
680
5b8719f5
DG
681/*
682 * set_signal_handler
683 *
684 * Setup signal handler for SIGCHLD and SIGTERM.
685 */
686static int set_signal_handler(void)
687{
688 int ret = 0;
689 struct sigaction sa;
690 sigset_t sigset;
691
692 if ((ret = sigemptyset(&sigset)) < 0) {
693 perror("sigemptyset");
694 goto end;
695 }
696
697 sa.sa_handler = sighandler;
698 sa.sa_mask = sigset;
699 sa.sa_flags = 0;
700 if ((ret = sigaction(SIGCHLD, &sa, NULL)) < 0) {
701 perror("sigaction");
702 goto end;
703 }
fac6795d 704
5b8719f5
DG
705 if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
706 perror("sigaction");
707 goto end;
708 }
709
710end:
711 return ret;
712}
713
714/*
715 * sighandler
716 *
717 * Signal handler for the daemon
718 */
719static void sighandler(int sig)
720{
5b8719f5
DG
721 switch (sig) {
722 case SIGTERM:
ce3d728c 723 DBG("SIGTERM catched");
5b8719f5
DG
724 clean_exit(EXIT_FAILURE);
725 break;
726 case SIGCHLD:
727 /* Notify is done */
ce3d728c 728 DBG("SIGCHLD catched");
5b8719f5
DG
729 break;
730 default:
ce3d728c 731 DBG("Unknown signal %d catched", sig);
5b8719f5
DG
732 break;
733 }
734
735 return;
736}
7442b2ba 737
fac6795d
DG
738/*
739 * clean_exit
740 */
741void clean_exit(int code)
742{
743 DBG("Clean exit");
96243366
DG
744 if (session_name) {
745 free(session_name);
746 }
747
fac6795d
DG
748 exit(code);
749}
750
751/*
5b8719f5 752 * main
fac6795d
DG
753 */
754int main(int argc, char *argv[])
755{
756 int ret;
757
758 progname = argv[0] ? argv[0] : "lttng";
759
760 /* For Mathieu Desnoyers aka Dr Tracing */
761 if (strncmp(progname, "drtrace", 7) == 0) {
762 MSG("%c[%d;%dmWelcome back Dr Tracing!%c[%dm\n\n", 27,1,33,27,0);
763 }
764
765 ret = parse_args(argc, (const char **) argv);
766 if (ret < 0) {
87378cf5 767 clean_exit(EXIT_FAILURE);
fac6795d
DG
768 }
769
8548ff30
DG
770 ret = validate_options();
771 if (ret < 0) {
772 return EXIT_FAILURE;
773 }
774
5b8719f5
DG
775 ret = set_signal_handler();
776 if (ret < 0) {
87378cf5 777 clean_exit(ret);
5b8719f5
DG
778 }
779
fac6795d
DG
780 if (opt_tracing_group != NULL) {
781 DBG("Set tracing group to '%s'", opt_tracing_group);
782 lttng_set_tracing_group(opt_tracing_group);
783 }
784
785 /* If ask for kernel tracing, need root perms */
786 if (opt_trace_kernel) {
787 DBG("Kernel tracing activated");
788 if (getuid() != 0) {
789 ERR("%s must be setuid root", progname);
87378cf5 790 clean_exit(-EPERM);
fac6795d
DG
791 }
792 }
793
794 /* Check if the lttng session daemon is running.
795 * If no, a daemon will be spawned.
796 */
5b8719f5 797 if (opt_no_sessiond == 0 && (check_ltt_sessiond() < 0)) {
87378cf5 798 clean_exit(EXIT_FAILURE);
fac6795d
DG
799 }
800
801 ret = process_client_opt();
802 if (ret < 0) {
87378cf5 803 clean_exit(ret);
fac6795d
DG
804 }
805
87378cf5
DG
806 clean_exit(0);
807
fac6795d
DG
808 return 0;
809}
This page took 0.05769 seconds and 4 git commands to generate.