+/*
+ * process_opt_list_sessions
+ *
+ * Get the list of available sessions from
+ * the session daemon and print it to user.
+ */
+static int process_opt_list_sessions(void)
+{
+ int ret, count, i;
+ struct lttng_session *sess;
+
+ count = lttng_list_sessions(&sess);
+ if (count < 0) {
+ ret = count;
+ goto error;
+ }
+
+ MSG("Available sessions [Name (uuid)]:");
+ for (i = 0; i < count; i++) {
+ MSG("\tName: %s (uuid: %s)", sess[i].name, sess[i].uuid);
+ }
+
+ free(sess);
+ MSG("\nTo select a session, use --session UUID.");
+
+ return 0;
+
+error:
+ return ret;
+}
+