nb_chan = session->kernel_session->channel_count;
}
DBG3("Number of kernel channels %zd", nb_chan);
+ if (nb_chan <= 0) {
+ ret = LTTCOMM_KERN_CHAN_NOT_FOUND;
+ }
break;
case LTTNG_DOMAIN_UST:
if (session->ust_session != NULL) {
session->ust_session->domain_global.channels);
}
DBG3("Number of UST global channels %zd", nb_chan);
+ if (nb_chan <= 0) {
+ ret = LTTCOMM_UST_CHAN_NOT_FOUND;
+ }
break;
default:
*channels = NULL;
list_lttng_channels(domain, session, *channels);
} else {
*channels = NULL;
+ /* Ret value was set in the domain switch case */
+ goto error;
}
return nb_chan;
rcu_register_thread();
- /* Create thread quit pipe */
- if ((ret = init_thread_quit_pipe()) < 0) {
- goto error;
- }
-
setup_consumerd_path();
/* Parse arguments */
/* Daemonize */
if (opt_daemon) {
+ int i;
+
+ /*
+ * fork
+ * child: setsid, close FD 0, 1, 2, chdir /
+ * parent: exit (if fork is successful)
+ */
ret = daemon(0, 0);
if (ret < 0) {
PERROR("daemon");
goto error;
}
+ /*
+ * We are in the child. Make sure all other file
+ * descriptors are closed, in case we are called with
+ * more opened file descriptors than the standard ones.
+ */
+ for (i = 3; i < sysconf(_SC_OPEN_MAX); i++) {
+ (void) close(i);
+ }
+ }
+
+ /* Create thread quit pipe */
+ if ((ret = init_thread_quit_pipe()) < 0) {
+ goto error;
}
/* Check if daemon is UID = 0 */