2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
3 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * Copyright (C) 2013 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 * SPDX-License-Identifier: GPL-2.0-only
22 #include <sys/mount.h>
23 #include <sys/resource.h>
24 #include <sys/socket.h>
26 #include <sys/types.h>
28 #include <urcu/uatomic.h>
32 #include <common/common.h>
33 #include <common/compat/socket.h>
34 #include <common/compat/getenv.h>
35 #include <common/defaults.h>
36 #include <common/kernel-consumer/kernel-consumer.h>
37 #include <common/futex.h>
38 #include <common/relayd/relayd.h>
39 #include <common/utils.h>
40 #include <common/daemonize.h>
41 #include <common/config/session-config.h>
42 #include <common/dynamic-buffer.h>
43 #include <lttng/event-internal.h>
45 #include "lttng-sessiond.h"
46 #include "buffer-registry.h"
53 #include "kernel-consumer.h"
54 #include "lttng-ust-ctl.h"
55 #include "ust-consumer.h"
58 #include "health-sessiond.h"
59 #include "testpoint.h"
60 #include "notify-apps.h"
61 #include "agent-thread.h"
63 #include "notification-thread.h"
64 #include "notification-thread-commands.h"
65 #include "rotation-thread.h"
67 #include "ht-cleanup.h"
68 #include "sessiond-config.h"
74 #include "manage-apps.h"
75 #include "manage-kernel.h"
77 static const char *help_msg
=
78 #ifdef LTTNG_EMBED_HELP
79 #include <lttng-sessiond.8.h>
86 static int lockfile_fd
= -1;
87 static int opt_print_version
;
89 /* Set to 1 when a SIGUSR1 signal is received. */
90 static int recv_child_signal
;
92 /* Command line options */
93 static const struct option long_options
[] = {
94 { "client-sock", required_argument
, 0, 'c' },
95 { "apps-sock", required_argument
, 0, 'a' },
96 { "kconsumerd-cmd-sock", required_argument
, 0, '\0' },
97 { "kconsumerd-err-sock", required_argument
, 0, '\0' },
98 { "ustconsumerd32-cmd-sock", required_argument
, 0, '\0' },
99 { "ustconsumerd32-err-sock", required_argument
, 0, '\0' },
100 { "ustconsumerd64-cmd-sock", required_argument
, 0, '\0' },
101 { "ustconsumerd64-err-sock", required_argument
, 0, '\0' },
102 { "consumerd32-path", required_argument
, 0, '\0' },
103 { "consumerd32-libdir", required_argument
, 0, '\0' },
104 { "consumerd64-path", required_argument
, 0, '\0' },
105 { "consumerd64-libdir", required_argument
, 0, '\0' },
106 { "daemonize", no_argument
, 0, 'd' },
107 { "background", no_argument
, 0, 'b' },
108 { "sig-parent", no_argument
, 0, 'S' },
109 { "help", no_argument
, 0, 'h' },
110 { "group", required_argument
, 0, 'g' },
111 { "version", no_argument
, 0, 'V' },
112 { "quiet", no_argument
, 0, 'q' },
113 { "verbose", no_argument
, 0, 'v' },
114 { "verbose-consumer", no_argument
, 0, '\0' },
115 { "no-kernel", no_argument
, 0, '\0' },
116 { "pidfile", required_argument
, 0, 'p' },
117 { "agent-tcp-port", required_argument
, 0, '\0' },
118 { "config", required_argument
, 0, 'f' },
119 { "load", required_argument
, 0, 'l' },
120 { "kmod-probes", required_argument
, 0, '\0' },
121 { "extra-kmod-probes", required_argument
, 0, '\0' },
125 /* Command line options to ignore from configuration file */
126 static const char *config_ignore_options
[] = { "help", "version", "config" };
129 * This pipe is used to inform the thread managing application communication
130 * that a command is queued and ready to be processed.
132 static int apps_cmd_pipe
[2] = { -1, -1 };
133 static int apps_cmd_notify_pipe
[2] = { -1, -1 };
136 * UST registration command queue. This queue is tied with a futex and uses a N
137 * wakers / 1 waiter implemented and detailed in futex.c/.h
139 * The thread_registration_apps and thread_dispatch_ust_registration uses this
140 * queue along with the wait/wake scheme. The thread_manage_apps receives down
141 * the line new application socket and monitors it for any I/O error or clean
142 * close that triggers an unregistration of the application.
144 static struct ust_cmd_queue ust_cmd_queue
;
147 * Section name to look for in the daemon configuration file.
149 static const char * const config_section_name
= "sessiond";
151 /* Am I root or not. Set to 1 if the daemon is running as root */
155 * Stop all threads by closing the thread quit pipe.
157 static void stop_threads(void)
161 /* Stopping all threads */
162 DBG("Terminating all threads");
163 ret
= sessiond_notify_quit_pipe();
165 ERR("write error on thread quit pipe");
170 * Close every consumer sockets.
172 static void close_consumer_sockets(void)
176 if (kconsumer_data
.err_sock
>= 0) {
177 ret
= close(kconsumer_data
.err_sock
);
179 PERROR("kernel consumer err_sock close");
182 if (ustconsumer32_data
.err_sock
>= 0) {
183 ret
= close(ustconsumer32_data
.err_sock
);
185 PERROR("UST consumerd32 err_sock close");
188 if (ustconsumer64_data
.err_sock
>= 0) {
189 ret
= close(ustconsumer64_data
.err_sock
);
191 PERROR("UST consumerd64 err_sock close");
194 if (kconsumer_data
.cmd_sock
>= 0) {
195 ret
= close(kconsumer_data
.cmd_sock
);
197 PERROR("kernel consumer cmd_sock close");
200 if (ustconsumer32_data
.cmd_sock
>= 0) {
201 ret
= close(ustconsumer32_data
.cmd_sock
);
203 PERROR("UST consumerd32 cmd_sock close");
206 if (ustconsumer64_data
.cmd_sock
>= 0) {
207 ret
= close(ustconsumer64_data
.cmd_sock
);
209 PERROR("UST consumerd64 cmd_sock close");
212 if (kconsumer_data
.channel_monitor_pipe
>= 0) {
213 ret
= close(kconsumer_data
.channel_monitor_pipe
);
215 PERROR("kernel consumer channel monitor pipe close");
218 if (ustconsumer32_data
.channel_monitor_pipe
>= 0) {
219 ret
= close(ustconsumer32_data
.channel_monitor_pipe
);
221 PERROR("UST consumerd32 channel monitor pipe close");
224 if (ustconsumer64_data
.channel_monitor_pipe
>= 0) {
225 ret
= close(ustconsumer64_data
.channel_monitor_pipe
);
227 PERROR("UST consumerd64 channel monitor pipe close");
233 * Wait on consumer process termination.
235 * Need to be called with the consumer data lock held or from a context
236 * ensuring no concurrent access to data (e.g: cleanup).
238 static void wait_consumer(struct consumer_data
*consumer_data
)
243 if (consumer_data
->pid
<= 0) {
247 DBG("Waiting for complete teardown of consumerd (PID: %d)",
249 ret
= waitpid(consumer_data
->pid
, &status
, 0);
251 PERROR("consumerd waitpid pid: %d", consumer_data
->pid
)
252 } else if (!WIFEXITED(status
)) {
253 ERR("consumerd termination with error: %d",
256 consumer_data
->pid
= 0;
260 * Cleanup the session daemon's data structures.
262 static void sessiond_cleanup(void)
265 struct ltt_session_list
*session_list
= session_get_list();
267 DBG("Cleanup sessiond");
270 * Close the thread quit pipe. It has already done its job,
271 * since we are now called.
273 sessiond_close_quit_pipe();
274 utils_close_pipe(apps_cmd_pipe
);
275 utils_close_pipe(apps_cmd_notify_pipe
);
276 utils_close_pipe(kernel_poll_pipe
);
278 ret
= remove(config
.pid_file_path
.value
);
280 PERROR("remove pidfile %s", config
.pid_file_path
.value
);
283 DBG("Removing sessiond and consumerd content of directory %s",
284 config
.rundir
.value
);
287 DBG("Removing %s", config
.pid_file_path
.value
);
288 (void) unlink(config
.pid_file_path
.value
);
290 DBG("Removing %s", config
.agent_port_file_path
.value
);
291 (void) unlink(config
.agent_port_file_path
.value
);
294 DBG("Removing %s", kconsumer_data
.err_unix_sock_path
);
295 (void) unlink(kconsumer_data
.err_unix_sock_path
);
297 DBG("Removing directory %s", config
.kconsumerd_path
.value
);
298 (void) rmdir(config
.kconsumerd_path
.value
);
300 /* ust consumerd 32 */
301 DBG("Removing %s", config
.consumerd32_err_unix_sock_path
.value
);
302 (void) unlink(config
.consumerd32_err_unix_sock_path
.value
);
304 DBG("Removing directory %s", config
.consumerd32_path
.value
);
305 (void) rmdir(config
.consumerd32_path
.value
);
307 /* ust consumerd 64 */
308 DBG("Removing %s", config
.consumerd64_err_unix_sock_path
.value
);
309 (void) unlink(config
.consumerd64_err_unix_sock_path
.value
);
311 DBG("Removing directory %s", config
.consumerd64_path
.value
);
312 (void) rmdir(config
.consumerd64_path
.value
);
314 pthread_mutex_destroy(&session_list
->lock
);
316 DBG("Cleaning up all per-event notifier domain agents");
317 agent_by_event_notifier_domain_ht_destroy();
319 DBG("Cleaning up all agent apps");
320 agent_app_ht_clean();
321 DBG("Closing all UST sockets");
322 ust_app_clean_list();
323 buffer_reg_destroy_registries();
325 close_consumer_sockets();
327 wait_consumer(&kconsumer_data
);
328 wait_consumer(&ustconsumer64_data
);
329 wait_consumer(&ustconsumer32_data
);
331 if (is_root
&& !config
.no_kernel
) {
332 cleanup_kernel_tracer();
336 * We do NOT rmdir rundir because there are other processes
337 * using it, for instance lttng-relayd, which can start in
338 * parallel with this teardown.
343 * Cleanup the daemon's option data structures.
345 static void sessiond_cleanup_options(void)
347 DBG("Cleaning up options");
349 sessiond_config_fini(&config
);
351 run_as_destroy_worker();
354 static int string_match(const char *str1
, const char *str2
)
356 return (str1
&& str2
) && !strcmp(str1
, str2
);
360 * Take an option from the getopt output and set it in the right variable to be
363 * Return 0 on success else a negative value.
365 static int set_option(int opt
, const char *arg
, const char *optname
)
369 if (string_match(optname
, "client-sock") || opt
== 'c') {
370 if (!arg
|| *arg
== '\0') {
374 if (lttng_is_setuid_setgid()) {
375 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
376 "-c, --client-sock");
378 config_string_set(&config
.client_unix_sock_path
,
380 if (!config
.client_unix_sock_path
.value
) {
385 } else if (string_match(optname
, "apps-sock") || opt
== 'a') {
386 if (!arg
|| *arg
== '\0') {
390 if (lttng_is_setuid_setgid()) {
391 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
394 config_string_set(&config
.apps_unix_sock_path
,
396 if (!config
.apps_unix_sock_path
.value
) {
401 } else if (string_match(optname
, "daemonize") || opt
== 'd') {
402 config
.daemonize
= true;
403 } else if (string_match(optname
, "background") || opt
== 'b') {
404 config
.background
= true;
405 } else if (string_match(optname
, "group") || opt
== 'g') {
406 if (!arg
|| *arg
== '\0') {
410 if (lttng_is_setuid_setgid()) {
411 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
414 config_string_set(&config
.tracing_group_name
,
416 if (!config
.tracing_group_name
.value
) {
421 } else if (string_match(optname
, "help") || opt
== 'h') {
422 ret
= utils_show_help(8, "lttng-sessiond", help_msg
);
424 ERR("Cannot show --help for `lttng-sessiond`");
427 exit(ret
? EXIT_FAILURE
: EXIT_SUCCESS
);
428 } else if (string_match(optname
, "version") || opt
== 'V') {
429 opt_print_version
= 1;
430 } else if (string_match(optname
, "sig-parent") || opt
== 'S') {
431 config
.sig_parent
= true;
432 } else if (string_match(optname
, "kconsumerd-err-sock")) {
433 if (!arg
|| *arg
== '\0') {
437 if (lttng_is_setuid_setgid()) {
438 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
439 "--kconsumerd-err-sock");
441 config_string_set(&config
.kconsumerd_err_unix_sock_path
,
443 if (!config
.kconsumerd_err_unix_sock_path
.value
) {
448 } else if (string_match(optname
, "kconsumerd-cmd-sock")) {
449 if (!arg
|| *arg
== '\0') {
453 if (lttng_is_setuid_setgid()) {
454 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
455 "--kconsumerd-cmd-sock");
457 config_string_set(&config
.kconsumerd_cmd_unix_sock_path
,
459 if (!config
.kconsumerd_cmd_unix_sock_path
.value
) {
464 } else if (string_match(optname
, "ustconsumerd64-err-sock")) {
465 if (!arg
|| *arg
== '\0') {
469 if (lttng_is_setuid_setgid()) {
470 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
471 "--ustconsumerd64-err-sock");
473 config_string_set(&config
.consumerd64_err_unix_sock_path
,
475 if (!config
.consumerd64_err_unix_sock_path
.value
) {
480 } else if (string_match(optname
, "ustconsumerd64-cmd-sock")) {
481 if (!arg
|| *arg
== '\0') {
485 if (lttng_is_setuid_setgid()) {
486 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
487 "--ustconsumerd64-cmd-sock");
489 config_string_set(&config
.consumerd64_cmd_unix_sock_path
,
491 if (!config
.consumerd64_cmd_unix_sock_path
.value
) {
496 } else if (string_match(optname
, "ustconsumerd32-err-sock")) {
497 if (!arg
|| *arg
== '\0') {
501 if (lttng_is_setuid_setgid()) {
502 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
503 "--ustconsumerd32-err-sock");
505 config_string_set(&config
.consumerd32_err_unix_sock_path
,
507 if (!config
.consumerd32_err_unix_sock_path
.value
) {
512 } else if (string_match(optname
, "ustconsumerd32-cmd-sock")) {
513 if (!arg
|| *arg
== '\0') {
517 if (lttng_is_setuid_setgid()) {
518 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
519 "--ustconsumerd32-cmd-sock");
521 config_string_set(&config
.consumerd32_cmd_unix_sock_path
,
523 if (!config
.consumerd32_cmd_unix_sock_path
.value
) {
528 } else if (string_match(optname
, "no-kernel")) {
529 config
.no_kernel
= true;
530 } else if (string_match(optname
, "quiet") || opt
== 'q') {
532 } else if (string_match(optname
, "verbose") || opt
== 'v') {
533 /* Verbose level can increase using multiple -v */
535 /* Value obtained from config file */
536 config
.verbose
= config_parse_value(arg
);
538 /* -v used on command line */
541 /* Clamp value to [0, 3] */
542 config
.verbose
= config
.verbose
< 0 ? 0 :
543 (config
.verbose
<= 3 ? config
.verbose
: 3);
544 } else if (string_match(optname
, "verbose-consumer")) {
546 config
.verbose_consumer
= config_parse_value(arg
);
548 config
.verbose_consumer
++;
550 } else if (string_match(optname
, "consumerd32-path")) {
551 if (!arg
|| *arg
== '\0') {
555 if (lttng_is_setuid_setgid()) {
556 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
557 "--consumerd32-path");
559 config_string_set(&config
.consumerd32_bin_path
,
561 if (!config
.consumerd32_bin_path
.value
) {
566 } else if (string_match(optname
, "consumerd32-libdir")) {
567 if (!arg
|| *arg
== '\0') {
571 if (lttng_is_setuid_setgid()) {
572 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
573 "--consumerd32-libdir");
575 config_string_set(&config
.consumerd32_lib_dir
,
577 if (!config
.consumerd32_lib_dir
.value
) {
582 } else if (string_match(optname
, "consumerd64-path")) {
583 if (!arg
|| *arg
== '\0') {
587 if (lttng_is_setuid_setgid()) {
588 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
589 "--consumerd64-path");
591 config_string_set(&config
.consumerd64_bin_path
,
593 if (!config
.consumerd64_bin_path
.value
) {
598 } else if (string_match(optname
, "consumerd64-libdir")) {
599 if (!arg
|| *arg
== '\0') {
603 if (lttng_is_setuid_setgid()) {
604 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
605 "--consumerd64-libdir");
607 config_string_set(&config
.consumerd64_lib_dir
,
609 if (!config
.consumerd64_lib_dir
.value
) {
614 } else if (string_match(optname
, "pidfile") || opt
== 'p') {
615 if (!arg
|| *arg
== '\0') {
619 if (lttng_is_setuid_setgid()) {
620 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
623 config_string_set(&config
.pid_file_path
, strdup(arg
));
624 if (!config
.pid_file_path
.value
) {
629 } else if (string_match(optname
, "agent-tcp-port")) {
630 if (!arg
|| *arg
== '\0') {
634 if (lttng_is_setuid_setgid()) {
635 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
641 v
= strtoul(arg
, NULL
, 0);
642 if (errno
!= 0 || !isdigit(arg
[0])) {
643 ERR("Wrong value in --agent-tcp-port parameter: %s", arg
);
646 if (v
== 0 || v
>= 65535) {
647 ERR("Port overflow in --agent-tcp-port parameter: %s", arg
);
650 config
.agent_tcp_port
.begin
= config
.agent_tcp_port
.end
= (int) v
;
651 DBG3("Agent TCP port set to non default: %i", (int) v
);
653 } else if (string_match(optname
, "load") || opt
== 'l') {
654 if (!arg
|| *arg
== '\0') {
658 if (lttng_is_setuid_setgid()) {
659 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
662 config_string_set(&config
.load_session_path
, strdup(arg
));
663 if (!config
.load_session_path
.value
) {
668 } else if (string_match(optname
, "kmod-probes")) {
669 if (!arg
|| *arg
== '\0') {
673 if (lttng_is_setuid_setgid()) {
674 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
677 config_string_set(&config
.kmod_probes_list
, strdup(arg
));
678 if (!config
.kmod_probes_list
.value
) {
683 } else if (string_match(optname
, "extra-kmod-probes")) {
684 if (!arg
|| *arg
== '\0') {
688 if (lttng_is_setuid_setgid()) {
689 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
690 "--extra-kmod-probes");
692 config_string_set(&config
.kmod_extra_probes_list
,
694 if (!config
.kmod_extra_probes_list
.value
) {
699 } else if (string_match(optname
, "config") || opt
== 'f') {
700 /* This is handled in set_options() thus silent skip. */
703 /* Unknown option or other error.
704 * Error is printed by getopt, just return */
709 if (ret
== -EINVAL
) {
710 const char *opt_name
= "unknown";
713 for (i
= 0; i
< sizeof(long_options
) / sizeof(struct option
);
715 if (opt
== long_options
[i
].val
) {
716 opt_name
= long_options
[i
].name
;
721 WARN("Invalid argument provided for option \"%s\", using default value.",
729 * config_entry_handler_cb used to handle options read from a config file.
730 * See config_entry_handler_cb comment in common/config/session-config.h for the
731 * return value conventions.
733 static int config_entry_handler(const struct config_entry
*entry
, void *unused
)
737 if (!entry
|| !entry
->name
|| !entry
->value
) {
742 /* Check if the option is to be ignored */
743 for (i
= 0; i
< sizeof(config_ignore_options
) / sizeof(char *); i
++) {
744 if (!strcmp(entry
->name
, config_ignore_options
[i
])) {
749 for (i
= 0; i
< (sizeof(long_options
) / sizeof(struct option
)) - 1;
752 /* Ignore if not fully matched. */
753 if (strcmp(entry
->name
, long_options
[i
].name
)) {
758 * If the option takes no argument on the command line, we have to
759 * check if the value is "true". We support non-zero numeric values,
762 if (!long_options
[i
].has_arg
) {
763 ret
= config_parse_value(entry
->value
);
766 WARN("Invalid configuration value \"%s\" for option %s",
767 entry
->value
, entry
->name
);
769 /* False, skip boolean config option. */
774 ret
= set_option(long_options
[i
].val
, entry
->value
, entry
->name
);
778 WARN("Unrecognized option \"%s\" in daemon configuration file.", entry
->name
);
784 static void print_version(void) {
785 fprintf(stdout
, "%s\n", VERSION
);
789 * daemon configuration loading and argument parsing
791 static int set_options(int argc
, char **argv
)
793 int ret
= 0, c
= 0, option_index
= 0;
794 int orig_optopt
= optopt
, orig_optind
= optind
;
796 const char *config_path
= NULL
;
798 optstring
= utils_generate_optstring(long_options
,
799 sizeof(long_options
) / sizeof(struct option
));
805 /* Check for the --config option */
806 while ((c
= getopt_long(argc
, argv
, optstring
, long_options
,
807 &option_index
)) != -1) {
811 } else if (c
!= 'f') {
812 /* if not equal to --config option. */
816 if (lttng_is_setuid_setgid()) {
817 WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
820 config_path
= utils_expand_path(optarg
);
822 ERR("Failed to resolve path: %s", optarg
);
827 ret
= config_get_section_entries(config_path
, config_section_name
,
828 config_entry_handler
, NULL
);
831 ERR("Invalid configuration option at line %i", ret
);
837 /* Reset getopt's global state */
838 optopt
= orig_optopt
;
839 optind
= orig_optind
;
843 * getopt_long() will not set option_index if it encounters a
846 c
= getopt_long(argc
, argv
, optstring
, long_options
,
853 * Pass NULL as the long option name if popt left the index
856 ret
= set_option(c
, optarg
,
857 option_index
< 0 ? NULL
:
858 long_options
[option_index
].name
);
870 * Create lockfile using the rundir and return its fd.
872 static int create_lockfile(void)
874 return utils_create_lock_file(config
.lock_file_path
.value
);
878 * Check if the global socket is available, and if a daemon is answering at the
879 * other side. If yes, error is returned.
881 * Also attempts to create and hold the lock file.
883 static int check_existing_daemon(void)
887 /* Is there anybody out there ? */
888 if (lttng_session_daemon_alive()) {
893 lockfile_fd
= create_lockfile();
894 if (lockfile_fd
< 0) {
902 static void sessiond_cleanup_lock_file(void)
907 * Cleanup lock file by deleting it and finaly closing it which will
908 * release the file system lock.
910 if (lockfile_fd
>= 0) {
911 ret
= remove(config
.lock_file_path
.value
);
913 PERROR("remove lock file");
915 ret
= close(lockfile_fd
);
917 PERROR("close lock file");
923 * Set the tracing group gid onto the client socket.
925 * Race window between mkdir and chown is OK because we are going from more
926 * permissive (root.root) to less permissive (root.tracing).
928 static int set_permissions(char *rundir
)
933 ret
= utils_get_group_id(config
.tracing_group_name
.value
, true, &gid
);
935 /* Default to root group. */
939 /* Set lttng run dir */
940 ret
= chown(rundir
, 0, gid
);
942 ERR("Unable to set group on %s", rundir
);
947 * Ensure all applications and tracing group can search the run
948 * dir. Allow everyone to read the directory, since it does not
949 * buy us anything to hide its content.
951 ret
= chmod(rundir
, S_IRWXU
| S_IRGRP
| S_IXGRP
| S_IROTH
| S_IXOTH
);
953 ERR("Unable to set permissions on %s", rundir
);
957 /* lttng client socket path */
958 ret
= chown(config
.client_unix_sock_path
.value
, 0, gid
);
960 ERR("Unable to set group on %s", config
.client_unix_sock_path
.value
);
964 /* kconsumer error socket path */
965 ret
= chown(kconsumer_data
.err_unix_sock_path
, 0, 0);
967 ERR("Unable to set group on %s", kconsumer_data
.err_unix_sock_path
);
971 /* 64-bit ustconsumer error socket path */
972 ret
= chown(ustconsumer64_data
.err_unix_sock_path
, 0, 0);
974 ERR("Unable to set group on %s", ustconsumer64_data
.err_unix_sock_path
);
978 /* 32-bit ustconsumer compat32 error socket path */
979 ret
= chown(ustconsumer32_data
.err_unix_sock_path
, 0, 0);
981 ERR("Unable to set group on %s", ustconsumer32_data
.err_unix_sock_path
);
985 DBG("All permissions are set");
991 * Create the lttng run directory needed for all global sockets and pipe.
993 static int create_lttng_rundir(void)
997 DBG3("Creating LTTng run directory: %s", config
.rundir
.value
);
999 ret
= mkdir(config
.rundir
.value
, S_IRWXU
);
1001 if (errno
!= EEXIST
) {
1002 ERR("Unable to create %s", config
.rundir
.value
);
1014 * Setup sockets and directory needed by the consumerds' communication with the
1017 static int set_consumer_sockets(struct consumer_data
*consumer_data
)
1022 switch (consumer_data
->type
) {
1023 case LTTNG_CONSUMER_KERNEL
:
1024 path
= config
.kconsumerd_path
.value
;
1026 case LTTNG_CONSUMER64_UST
:
1027 path
= config
.consumerd64_path
.value
;
1029 case LTTNG_CONSUMER32_UST
:
1030 path
= config
.consumerd32_path
.value
;
1033 ERR("Consumer type unknown");
1039 DBG2("Creating consumer directory: %s", path
);
1041 ret
= mkdir(path
, S_IRWXU
| S_IRGRP
| S_IXGRP
);
1042 if (ret
< 0 && errno
!= EEXIST
) {
1044 ERR("Failed to create %s", path
);
1050 ret
= utils_get_group_id(config
.tracing_group_name
.value
, true,
1053 /* Default to root group. */
1057 ret
= chown(path
, 0, gid
);
1059 ERR("Unable to set group on %s", path
);
1065 /* Create the consumerd error unix socket */
1066 consumer_data
->err_sock
=
1067 lttcomm_create_unix_sock(consumer_data
->err_unix_sock_path
);
1068 if (consumer_data
->err_sock
< 0) {
1069 ERR("Create unix sock failed: %s", consumer_data
->err_unix_sock_path
);
1075 * Set the CLOEXEC flag. Return code is useless because either way, the
1078 ret
= utils_set_fd_cloexec(consumer_data
->err_sock
);
1080 PERROR("utils_set_fd_cloexec");
1081 /* continue anyway */
1084 /* File permission MUST be 660 */
1085 ret
= chmod(consumer_data
->err_unix_sock_path
,
1086 S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
);
1088 ERR("Set file permissions failed: %s", consumer_data
->err_unix_sock_path
);
1098 * Signal handler for the daemon
1100 * Simply stop all worker threads, leaving main() return gracefully after
1101 * joining all threads and calling cleanup().
1103 static void sighandler(int sig
)
1107 DBG("SIGINT caught");
1111 DBG("SIGTERM caught");
1115 CMM_STORE_SHARED(recv_child_signal
, 1);
1123 * Setup signal handler for :
1124 * SIGINT, SIGTERM, SIGPIPE
1126 static int set_signal_handler(void)
1129 struct sigaction sa
;
1132 if ((ret
= sigemptyset(&sigset
)) < 0) {
1133 PERROR("sigemptyset");
1137 sa
.sa_mask
= sigset
;
1140 sa
.sa_handler
= sighandler
;
1141 if ((ret
= sigaction(SIGTERM
, &sa
, NULL
)) < 0) {
1142 PERROR("sigaction");
1146 if ((ret
= sigaction(SIGINT
, &sa
, NULL
)) < 0) {
1147 PERROR("sigaction");
1151 if ((ret
= sigaction(SIGUSR1
, &sa
, NULL
)) < 0) {
1152 PERROR("sigaction");
1156 sa
.sa_handler
= SIG_IGN
;
1157 if ((ret
= sigaction(SIGPIPE
, &sa
, NULL
)) < 0) {
1158 PERROR("sigaction");
1162 DBG("Signal handler set for SIGTERM, SIGUSR1, SIGPIPE and SIGINT");
1168 * Set open files limit to unlimited. This daemon can open a large number of
1169 * file descriptors in order to consume multiple kernel traces.
1171 static void set_ulimit(void)
1176 /* The kernel does not allow an infinite limit for open files */
1177 lim
.rlim_cur
= 65535;
1178 lim
.rlim_max
= 65535;
1180 ret
= setrlimit(RLIMIT_NOFILE
, &lim
);
1182 PERROR("failed to set open files limit");
1186 static int write_pidfile(void)
1188 return utils_create_pid_file(getpid(), config
.pid_file_path
.value
);
1191 static int set_clock_plugin_env(void)
1194 char *env_value
= NULL
;
1196 if (!config
.lttng_ust_clock_plugin
.value
) {
1200 ret
= asprintf(&env_value
, "LTTNG_UST_CLOCK_PLUGIN=%s",
1201 config
.lttng_ust_clock_plugin
.value
);
1207 ret
= putenv(env_value
);
1210 PERROR("putenv of LTTNG_UST_CLOCK_PLUGIN");
1214 DBG("Updated LTTNG_UST_CLOCK_PLUGIN environment variable to \"%s\"",
1215 config
.lttng_ust_clock_plugin
.value
);
1220 static void destroy_all_sessions_and_wait(void)
1222 struct ltt_session
*session
, *tmp
;
1223 struct ltt_session_list
*session_list
;
1225 session_list
= session_get_list();
1226 DBG("Initiating destruction of all sessions");
1228 if (!session_list
) {
1232 session_lock_list();
1233 /* Initiate the destruction of all sessions. */
1234 cds_list_for_each_entry_safe(session
, tmp
,
1235 &session_list
->head
, list
) {
1236 if (!session_get(session
)) {
1240 session_lock(session
);
1241 if (session
->destroyed
) {
1242 goto unlock_session
;
1244 (void) cmd_stop_trace(session
);
1245 (void) cmd_destroy_session(session
, notification_thread_handle
,
1248 session_unlock(session
);
1249 session_put(session
);
1251 session_unlock_list();
1253 /* Wait for the destruction of all sessions to complete. */
1254 DBG("Waiting for the destruction of all sessions to complete");
1255 session_list_wait_empty();
1256 DBG("Destruction of all sessions completed");
1259 static void unregister_all_triggers(void)
1261 enum lttng_error_code ret_code
;
1262 enum lttng_trigger_status trigger_status
;
1263 struct lttng_triggers
*triggers
= NULL
;
1264 unsigned int trigger_count
, i
;
1265 const struct lttng_credentials creds
= {
1266 .uid
= LTTNG_OPTIONAL_INIT_VALUE(0),
1269 DBG("Unregistering all triggers");
1272 * List all triggers as "root" since we wish to unregister all triggers.
1274 ret_code
= notification_thread_command_list_triggers(
1275 notification_thread_handle
, creds
.uid
.value
, &triggers
);
1276 if (ret_code
!= LTTNG_OK
) {
1277 ERR("Failed to list triggers while unregistering all triggers");
1281 trigger_status
= lttng_triggers_get_count(triggers
, &trigger_count
);
1282 assert(trigger_status
== LTTNG_TRIGGER_STATUS_OK
);
1284 for (i
= 0; i
< trigger_count
; i
++) {
1285 enum lttng_error_code ret_code
;
1286 uid_t trigger_owner
;
1287 const char *trigger_name
;
1288 const struct lttng_trigger
*trigger
=
1289 lttng_triggers_get_at_index(triggers
, i
);
1293 trigger_status
= lttng_trigger_get_owner_uid(
1294 trigger
, &trigger_owner
);
1295 assert(trigger_status
== LTTNG_TRIGGER_STATUS_OK
);
1297 trigger_status
= lttng_trigger_get_name(trigger
, &trigger_name
);
1298 assert(trigger_status
== LTTNG_TRIGGER_STATUS_OK
);
1300 DBG("Unregistering trigger: trigger owner uid = %d, trigger name = '%s'",
1301 (int) trigger_owner
, trigger_name
);
1303 ret_code
= cmd_unregister_trigger(
1304 &creds
, trigger
, notification_thread_handle
);
1305 if (ret_code
!= LTTNG_OK
) {
1306 ERR("Failed to unregister trigger: trigger owner uid = %d, trigger name = '%s', error: '%s'",
1307 (int) trigger_owner
, trigger_name
,
1308 lttng_strerror(-ret_code
));
1309 /* Continue to unregister the remaining triggers. */
1313 lttng_triggers_destroy(triggers
);
1316 static int run_as_worker_post_fork_cleanup(void *data
)
1318 struct sessiond_config
*sessiond_config
= data
;
1320 sessiond_config_fini(sessiond_config
);
1324 static int launch_run_as_worker(const char *procname
)
1327 * Clean-up before forking the run-as worker. Any dynamically
1328 * allocated memory of which the worker is not aware will
1329 * be leaked as the process forks a run-as worker (and performs
1330 * no exec*()). The same would apply to any opened fd.
1332 return run_as_create_worker(procname
, run_as_worker_post_fork_cleanup
,
1336 static void sessiond_uuid_log(void)
1338 char uuid_str
[LTTNG_UUID_STR_LEN
];
1340 lttng_uuid_to_str(sessiond_uuid
, uuid_str
);
1341 DBG("Starting lttng-sessiond {%s}", uuid_str
);
1347 int main(int argc
, char **argv
)
1349 int ret
= 0, retval
= 0;
1350 const char *env_app_timeout
;
1351 struct lttng_pipe
*ust32_channel_monitor_pipe
= NULL
,
1352 *ust64_channel_monitor_pipe
= NULL
,
1353 *kernel_channel_monitor_pipe
= NULL
;
1354 struct lttng_thread
*ht_cleanup_thread
= NULL
;
1355 struct timer_thread_parameters timer_thread_parameters
;
1356 /* Rotation thread handle. */
1357 struct rotation_thread_handle
*rotation_thread_handle
= NULL
;
1358 /* Queue of rotation jobs populated by the sessiond-timer. */
1359 struct rotation_thread_timer_queue
*rotation_timer_queue
= NULL
;
1360 struct lttng_thread
*client_thread
= NULL
;
1361 struct lttng_thread
*notification_thread
= NULL
;
1362 struct lttng_thread
*register_apps_thread
= NULL
;
1364 logger_set_thread_name("Main", false);
1365 init_kernel_workarounds();
1367 rcu_register_thread();
1369 if (set_signal_handler()) {
1371 goto exit_set_signal_handler
;
1374 if (timer_signal_init()) {
1376 goto exit_set_signal_handler
;
1379 page_size
= sysconf(_SC_PAGESIZE
);
1380 if (page_size
< 0) {
1381 PERROR("sysconf _SC_PAGESIZE");
1382 page_size
= LONG_MAX
;
1383 WARN("Fallback page size to %ld", page_size
);
1386 ret
= sessiond_config_init(&config
);
1389 goto exit_set_signal_handler
;
1393 * Init config from environment variables.
1394 * Command line option override env configuration per-doc. Do env first.
1396 sessiond_config_apply_env_config(&config
);
1399 * Parse arguments and load the daemon configuration file.
1401 * We have an exit_options exit path to free memory reserved by
1402 * set_options. This is needed because the rest of sessiond_cleanup()
1403 * depends on ht_cleanup_thread, which depends on lttng_daemonize, which
1404 * depends on set_options.
1407 if (set_options(argc
, argv
)) {
1413 * Resolve all paths received as arguments, configuration option, or
1414 * through environment variable as absolute paths. This is necessary
1415 * since daemonizing causes the sessiond's current working directory
1418 ret
= sessiond_config_resolve_paths(&config
);
1424 lttng_opt_verbose
= config
.verbose
;
1425 lttng_opt_quiet
= config
.quiet
;
1426 kconsumer_data
.err_unix_sock_path
=
1427 config
.kconsumerd_err_unix_sock_path
.value
;
1428 kconsumer_data
.cmd_unix_sock_path
=
1429 config
.kconsumerd_cmd_unix_sock_path
.value
;
1430 ustconsumer32_data
.err_unix_sock_path
=
1431 config
.consumerd32_err_unix_sock_path
.value
;
1432 ustconsumer32_data
.cmd_unix_sock_path
=
1433 config
.consumerd32_cmd_unix_sock_path
.value
;
1434 ustconsumer64_data
.err_unix_sock_path
=
1435 config
.consumerd64_err_unix_sock_path
.value
;
1436 ustconsumer64_data
.cmd_unix_sock_path
=
1437 config
.consumerd64_cmd_unix_sock_path
.value
;
1438 set_clock_plugin_env();
1440 sessiond_config_log(&config
);
1441 sessiond_uuid_log();
1443 if (opt_print_version
) {
1449 if (create_lttng_rundir()) {
1454 /* Abort launch if a session daemon is already running. */
1455 if (check_existing_daemon()) {
1456 ERR("A session daemon is already running.");
1462 if (config
.daemonize
|| config
.background
) {
1465 ret
= lttng_daemonize(&child_ppid
, &recv_child_signal
,
1466 !config
.background
);
1473 * We are in the child. Make sure all other file descriptors are
1474 * closed, in case we are called with more opened file
1475 * descriptors than the standard ones and the lock file.
1477 for (i
= 3; i
< sysconf(_SC_OPEN_MAX
); i
++) {
1478 if (i
== lockfile_fd
) {
1485 if (launch_run_as_worker(argv
[0]) < 0) {
1486 goto exit_create_run_as_worker_cleanup
;
1490 * Starting from here, we can create threads. This needs to be after
1491 * lttng_daemonize due to RCU.
1495 * Initialize the health check subsystem. This call should set the
1496 * appropriate time values.
1498 health_sessiond
= health_app_create(NR_HEALTH_SESSIOND_TYPES
);
1499 if (!health_sessiond
) {
1500 PERROR("health_app_create error");
1505 /* Create thread to clean up RCU hash tables */
1506 ht_cleanup_thread
= launch_ht_cleanup_thread();
1507 if (!ht_cleanup_thread
) {
1512 /* Create thread quit pipe */
1513 if (sessiond_init_thread_quit_pipe()) {
1518 /* Check if daemon is UID = 0 */
1519 is_root
= !getuid();
1521 /* Create global run dir with root access */
1523 kernel_channel_monitor_pipe
= lttng_pipe_open(0);
1524 if (!kernel_channel_monitor_pipe
) {
1525 ERR("Failed to create kernel consumer channel monitor pipe");
1529 kconsumer_data
.channel_monitor_pipe
=
1530 lttng_pipe_release_writefd(
1531 kernel_channel_monitor_pipe
);
1532 if (kconsumer_data
.channel_monitor_pipe
< 0) {
1538 /* Set consumer initial state */
1539 kernel_consumerd_state
= CONSUMER_STOPPED
;
1540 ust_consumerd_state
= CONSUMER_STOPPED
;
1542 ust32_channel_monitor_pipe
= lttng_pipe_open(0);
1543 if (!ust32_channel_monitor_pipe
) {
1544 ERR("Failed to create 32-bit user space consumer channel monitor pipe");
1548 ustconsumer32_data
.channel_monitor_pipe
= lttng_pipe_release_writefd(
1549 ust32_channel_monitor_pipe
);
1550 if (ustconsumer32_data
.channel_monitor_pipe
< 0) {
1556 * The rotation_thread_timer_queue structure is shared between the
1557 * sessiond timer thread and the rotation thread. The main thread keeps
1558 * its ownership and destroys it when both threads have been joined.
1560 rotation_timer_queue
= rotation_thread_timer_queue_create();
1561 if (!rotation_timer_queue
) {
1565 timer_thread_parameters
.rotation_thread_job_queue
=
1566 rotation_timer_queue
;
1568 ust64_channel_monitor_pipe
= lttng_pipe_open(0);
1569 if (!ust64_channel_monitor_pipe
) {
1570 ERR("Failed to create 64-bit user space consumer channel monitor pipe");
1574 ustconsumer64_data
.channel_monitor_pipe
= lttng_pipe_release_writefd(
1575 ust64_channel_monitor_pipe
);
1576 if (ustconsumer64_data
.channel_monitor_pipe
< 0) {
1582 * Init UST app hash table. Alloc hash table before this point since
1583 * cleanup() can get called after that point.
1585 if (ust_app_ht_alloc()) {
1586 ERR("Failed to allocate UST app hash table");
1592 * Initialize agent app hash table. We allocate the hash table here
1593 * since cleanup() can get called after this point.
1595 if (agent_app_ht_alloc()) {
1596 ERR("Failed to allocate Agent app hash table");
1601 if (agent_by_event_notifier_domain_ht_create()) {
1602 ERR("Failed to allocate per-event notifier domain agent hash table");
1607 * These actions must be executed as root. We do that *after* setting up
1608 * the sockets path because we MUST make the check for another daemon using
1609 * those paths *before* trying to set the kernel consumer sockets and init
1613 if (set_consumer_sockets(&kconsumer_data
)) {
1618 /* Setup kernel tracer */
1619 if (!config
.no_kernel
) {
1620 init_kernel_tracer();
1623 /* Set ulimit for open files */
1626 /* init lttng_fd tracking must be done after set_ulimit. */
1629 if (set_consumer_sockets(&ustconsumer64_data
)) {
1634 if (set_consumer_sockets(&ustconsumer32_data
)) {
1639 /* Get parent pid if -S, --sig-parent is specified. */
1640 if (config
.sig_parent
) {
1644 /* Setup the kernel pipe for waking up the kernel thread */
1645 if (is_root
&& !config
.no_kernel
) {
1646 if (utils_create_pipe_cloexec(kernel_poll_pipe
)) {
1652 /* Setup the thread apps communication pipe. */
1653 if (utils_create_pipe_cloexec(apps_cmd_pipe
)) {
1658 /* Setup the thread apps notify communication pipe. */
1659 if (utils_create_pipe_cloexec(apps_cmd_notify_pipe
)) {
1664 /* Initialize global buffer per UID and PID registry. */
1665 buffer_reg_init_uid_registry();
1666 buffer_reg_init_pid_registry();
1668 /* Init UST command queue. */
1669 cds_wfcq_init(&ust_cmd_queue
.head
, &ust_cmd_queue
.tail
);
1673 /* Check for the application socket timeout env variable. */
1674 env_app_timeout
= getenv(DEFAULT_APP_SOCKET_TIMEOUT_ENV
);
1675 if (env_app_timeout
) {
1676 config
.app_socket_timeout
= atoi(env_app_timeout
);
1678 config
.app_socket_timeout
= DEFAULT_APP_SOCKET_RW_TIMEOUT
;
1681 ret
= write_pidfile();
1683 ERR("Error in write_pidfile");
1688 /* Initialize communication library */
1690 /* Initialize TCP timeout values */
1691 lttcomm_inet_init();
1693 /* Create health-check thread. */
1694 if (!launch_health_management_thread()) {
1699 /* notification_thread_data acquires the pipes' read side. */
1700 notification_thread_handle
= notification_thread_handle_create(
1701 ust32_channel_monitor_pipe
,
1702 ust64_channel_monitor_pipe
,
1703 kernel_channel_monitor_pipe
);
1704 if (!notification_thread_handle
) {
1706 ERR("Failed to create notification thread shared data");
1710 /* Create notification thread. */
1711 notification_thread
= launch_notification_thread(
1712 notification_thread_handle
);
1713 if (!notification_thread
) {
1718 /* Create timer thread. */
1719 if (!launch_timer_thread(&timer_thread_parameters
)) {
1724 /* rotation_thread_data acquires the pipes' read side. */
1725 rotation_thread_handle
= rotation_thread_handle_create(
1726 rotation_timer_queue
,
1727 notification_thread_handle
);
1728 if (!rotation_thread_handle
) {
1730 ERR("Failed to create rotation thread shared data");
1735 /* Create rotation thread. */
1736 if (!launch_rotation_thread(rotation_thread_handle
)) {
1741 /* Create thread to manage the client socket */
1742 client_thread
= launch_client_thread();
1743 if (!client_thread
) {
1748 /* Set credentials of the client socket and rundir */
1749 if (is_root
&& set_permissions(config
.rundir
.value
)) {
1754 if (!launch_ust_dispatch_thread(&ust_cmd_queue
, apps_cmd_pipe
[1],
1755 apps_cmd_notify_pipe
[1])) {
1760 /* Create thread to manage application registration. */
1761 register_apps_thread
= launch_application_registration_thread(
1763 if (!register_apps_thread
) {
1768 /* Create thread to manage application socket */
1769 if (!launch_application_management_thread(apps_cmd_pipe
[0])) {
1774 /* Create thread to manage application notify socket */
1775 if (!launch_application_notification_thread(apps_cmd_notify_pipe
[0])) {
1780 /* Create agent management thread. */
1781 if (!launch_agent_management_thread()) {
1786 /* Don't start this thread if kernel tracing is not requested nor root */
1787 if (is_root
&& !config
.no_kernel
) {
1788 /* Create kernel thread to manage kernel event */
1789 if (!launch_kernel_management_thread(kernel_poll_pipe
[0])) {
1794 if (kernel_get_notification_fd() >= 0) {
1795 ret
= notification_thread_command_add_tracer_event_source(
1796 notification_thread_handle
,
1797 kernel_get_notification_fd(),
1798 LTTNG_DOMAIN_KERNEL
);
1799 if (ret
!= LTTNG_OK
) {
1800 ERR("Failed to add kernel trigger event source to notification thread");
1807 /* Load sessions. */
1808 ret
= config_load_session(config
.load_session_path
.value
,
1811 ERR("Session load failed: %s", error_get_str(ret
));
1816 /* Initialization completed. */
1817 sessiond_signal_parents();
1820 * This is where we start awaiting program completion (e.g. through
1821 * signal that asks threads to teardown).
1824 /* Initiate teardown once activity occurs on the quit pipe. */
1825 sessiond_wait_for_quit_pipe(-1);
1829 * Ensure that the client thread is no longer accepting new commands,
1830 * which could cause new sessions to be created.
1832 if (client_thread
) {
1833 lttng_thread_shutdown(client_thread
);
1834 lttng_thread_put(client_thread
);
1837 destroy_all_sessions_and_wait();
1840 * At this point no new trigger can be registered (no sessions are
1841 * running/rotating) and clients can't connect to the session daemon
1842 * anymore. Unregister all triggers.
1844 unregister_all_triggers();
1846 if (register_apps_thread
) {
1847 lttng_thread_shutdown(register_apps_thread
);
1848 lttng_thread_put(register_apps_thread
);
1850 lttng_thread_list_shutdown_orphans();
1853 * Wait for all pending call_rcu work to complete before tearing
1854 * down data structures. call_rcu worker may be trying to
1855 * perform lookups in those structures.
1859 * sessiond_cleanup() is called when no other thread is running, except
1860 * the ht_cleanup thread, which is needed to destroy the hash tables.
1862 rcu_thread_online();
1866 * Wait for all pending call_rcu work to complete tearing shutting down
1867 * the notification thread. This call_rcu work includes shutting down
1868 * UST apps and event notifier pipes.
1872 if (notification_thread
) {
1873 lttng_thread_shutdown(notification_thread
);
1874 lttng_thread_put(notification_thread
);
1878 * Ensure all prior call_rcu are done. call_rcu callbacks may push
1879 * hash tables to the ht_cleanup thread. Therefore, we ensure that
1880 * the queue is empty before shutting down the clean-up thread.
1884 if (ht_cleanup_thread
) {
1885 lttng_thread_shutdown(ht_cleanup_thread
);
1886 lttng_thread_put(ht_cleanup_thread
);
1889 rcu_thread_offline();
1890 rcu_unregister_thread();
1892 if (rotation_thread_handle
) {
1893 rotation_thread_handle_destroy(rotation_thread_handle
);
1897 * After the rotation and timer thread have quit, we can safely destroy
1898 * the rotation_timer_queue.
1900 rotation_thread_timer_queue_destroy(rotation_timer_queue
);
1902 * The teardown of the notification system is performed after the
1903 * session daemon's teardown in order to allow it to be notified
1904 * of the active session and channels at the moment of the teardown.
1906 if (notification_thread_handle
) {
1907 notification_thread_handle_destroy(notification_thread_handle
);
1909 lttng_pipe_destroy(ust32_channel_monitor_pipe
);
1910 lttng_pipe_destroy(ust64_channel_monitor_pipe
);
1911 lttng_pipe_destroy(kernel_channel_monitor_pipe
);
1913 if (health_sessiond
) {
1914 health_app_destroy(health_sessiond
);
1916 exit_create_run_as_worker_cleanup
:
1918 sessiond_cleanup_lock_file();
1919 sessiond_cleanup_options();
1921 exit_set_signal_handler
: