X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=004b0ccebf1c7b24e49674e2f3d66d53bfde7abe;hp=c2210f48aa484c94393003e9f5b782ddbc5770c4;hb=a5dfbb9db7ba31913657ed921006b13977b7b426;hpb=a9ad0c8fb50ac8cf9e9812dd9c9b4f949bac19a8 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index c2210f48a..004b0cceb 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1990,6 +1990,51 @@ end: return ret; } +/* + * List PIDs in the tracker. + * + * @enabled is set to whether the PID tracker is enabled. + * @pids is set to an allocated array of PIDs currently tracked. On + * success, @pids must be freed by the caller. + * @nr_pids is set to the number of entries contained by the @pids array. + * + * Returns 0 on success, else a negative LTTng error code. + */ +int lttng_list_tracker_pids(struct lttng_handle *handle, + int *_enabled, int32_t **_pids, size_t *_nr_pids) +{ + int ret, enabled = 1; + struct lttcomm_session_msg lsm; + size_t nr_pids; + int32_t *pids; + + if (handle == NULL) { + return -LTTNG_ERR_INVALID; + } + + memset(&lsm, 0, sizeof(lsm)); + lsm.cmd_type = LTTNG_LIST_TRACKER_PIDS; + lttng_ctl_copy_string(lsm.session.name, handle->session_name, + sizeof(lsm.session.name)); + lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain); + + ret = lttng_ctl_ask_sessiond(&lsm, (void **) &pids); + if (ret < 0) { + return ret; + } + nr_pids = ret / sizeof(int32_t); + if (nr_pids == 1 && pids[0] == -1) { + free(pids); + pids = NULL; + enabled = 0; + nr_pids = 0; + } + *_enabled = enabled; + *_pids = pids; + *_nr_pids = nr_pids; + return 0; +} + /* * lib constructor */