+ if (ret) {
+ errno = ret;
+ PERROR("pthread_create");
+ retval = -1;
+ goto exit_metadata_thread;
+ }
+
+ /* Create thread to manage the polling/writing of trace data */
+ ret = pthread_create(&data_thread, default_pthread_attr(),
+ consumer_thread_data_poll, (void *) ctx);
+ if (ret) {
+ errno = ret;
+ PERROR("pthread_create");
+ retval = -1;
+ goto exit_data_thread;
+ }
+
+ /* Create the thread to manage the reception of fds */
+ ret = pthread_create(&sessiond_thread, default_pthread_attr(),
+ consumer_thread_sessiond_poll,
+ (void *) ctx);
+ if (ret) {
+ errno = ret;
+ PERROR("pthread_create");
+ retval = -1;
+ goto exit_sessiond_thread;
+ }
+
+ /*
+ * Create the thread to manage the UST metadata periodic timer and
+ * live timer.
+ */
+ ret = pthread_create(&metadata_timer_thread, default_pthread_attr(),
+ consumer_timer_thread, (void *) ctx);
+ if (ret) {
+ errno = ret;
+ PERROR("pthread_create");
+ retval = -1;
+ goto exit_metadata_timer_thread;
+ }
+
+ ret = pthread_detach(metadata_timer_thread);
+ if (ret) {
+ errno = ret;
+ PERROR("pthread_detach");
+ retval = -1;
+ goto exit_metadata_timer_detach;
+ }
+
+ /*
+ * This is where we start awaiting program completion (e.g. through
+ * signal that asks threads to teardown.
+ */
+
+exit_metadata_timer_detach:
+exit_metadata_timer_thread:
+ ret = pthread_join(sessiond_thread, &status);
+ if (ret) {
+ errno = ret;
+ PERROR("pthread_join sessiond_thread");
+ retval = -1;