+
+static bool shutdown_agent_management_thread(void *data)
+{
+ struct thread_notifiers *notifiers = data;
+ const int write_fd = lttng_pipe_get_writefd(notifiers->quit_pipe);
+
+ return notify_thread_pipe(write_fd) == 1;
+}
+
+static void cleanup_agent_management_thread(void *data)
+{
+ struct thread_notifiers *notifiers = data;
+
+ lttng_pipe_destroy(notifiers->quit_pipe);
+ sem_destroy(¬ifiers->ready);
+ free(notifiers);
+}
+
+bool launch_agent_management_thread(void)
+{
+ struct thread_notifiers *notifiers;
+ struct lttng_thread *thread;
+
+ notifiers = zmalloc(sizeof(*notifiers));
+ if (!notifiers) {
+ goto error;
+ }
+
+ sem_init(¬ifiers->ready, 0, 0);
+ notifiers->quit_pipe = lttng_pipe_open(FD_CLOEXEC);
+ if (!notifiers->quit_pipe) {
+ goto error;
+ }
+ thread = lttng_thread_create("Agent management",
+ thread_agent_management,
+ shutdown_agent_management_thread,
+ cleanup_agent_management_thread,
+ notifiers);
+ if (!thread) {
+ goto error;
+ }
+ wait_until_thread_is_ready(notifiers);
+ lttng_thread_put(thread);
+ return true;
+error:
+ cleanup_agent_management_thread(notifiers);
+ return false;
+}