+/*
+ * ust_stop_trace
+ *
+ * Stop a trace. This trace, identified by the pid, must be
+ * in the current session ust_traces list.
+ */
+static int ust_stop_trace(pid_t pid)
+{
+ int sock, ret;
+ struct ltt_ust_trace *trace;
+
+ DBG("Stopping trace for pid %d", pid);
+
+ trace = find_session_ust_trace_by_pid(current_session, pid);
+ if (trace == NULL) {
+ ret = LTTCOMM_NO_TRACE;
+ goto error;
+ }
+
+ /* Connect to app using ustctl API */
+ sock = connect_app(pid);
+ if (sock < 0) {
+ ret = LTTCOMM_NO_TRACEABLE;
+ goto error;
+ }
+
+ ret = ustctl_stop_trace(sock, trace->name);
+ if (ret < 0) {
+ ret = LTTCOMM_STOP_FAIL;
+ goto error;
+ }
+
+error:
+ return ret;
+}
+