From: Mathieu Desnoyers Date: Wed, 2 Sep 2015 14:45:07 +0000 (-0400) Subject: Fix: kernel track/untrack error handling X-Git-Tag: v2.8.0-rc1~404 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7c493d31f0a1461e0f17a3fd494fef9459d1987c;p=lttng-tools.git Fix: kernel track/untrack error handling Fixes #918 Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 570747f18..381b83e63 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -379,16 +379,46 @@ error: int kernel_track_pid(struct ltt_kernel_session *session, int pid) { + int ret; + DBG("Kernel track PID %d for session id %" PRIu64 ".", pid, session->id); - return kernctl_track_pid(session->fd, pid); + ret = kernctl_track_pid(session->fd, pid); + if (!ret) { + return LTTNG_OK; + } + switch (errno) { + case EINVAL: + return LTTNG_ERR_INVALID; + case ENOMEM: + return LTTNG_ERR_NOMEM; + case EEXIST: + return LTTNG_ERR_PID_TRACKED; + default: + return LTTNG_ERR_UNK; + } } int kernel_untrack_pid(struct ltt_kernel_session *session, int pid) { + int ret; + DBG("Kernel untrack PID %d for session id %" PRIu64 ".", pid, session->id); - return kernctl_untrack_pid(session->fd, pid); + ret = kernctl_untrack_pid(session->fd, pid); + if (!ret) { + return LTTNG_OK; + } + switch (errno) { + case EINVAL: + return LTTNG_ERR_INVALID; + case ENOMEM: + return LTTNG_ERR_NOMEM; + case ENOENT: + return LTTNG_ERR_PID_NOT_TRACKED; + default: + return LTTNG_ERR_UNK; + } } ssize_t kernel_list_tracker_pids(struct ltt_kernel_session *session,