+/*
+ * Using a ust session list, it will return the session corresponding to the
+ * pid. Must be a session of domain LTTNG_DOMAIN_UST_PID.
+ */
+struct ltt_ust_session *trace_ust_get_session_by_pid(
+ struct ltt_ust_session_list *session_list, pid_t pid)
+{
+ struct ltt_ust_session *sess;
+
+ if (session_list == NULL) {
+ ERR("Session list is NULL");
+ goto error;
+ }
+
+ cds_list_for_each_entry(sess, &session_list->head, list) {
+ if (sess->domain.type == LTTNG_DOMAIN_UST_PID &&
+ sess->domain.attr.pid == pid) {
+ DBG2("Trace UST session found by pid %d", pid);
+ return sess;
+ }
+ }
+
+error:
+ return NULL;
+}
+