[ltt-dev] [UST PATCH] Get Online targets checker
Matthew Khouzam
matthew.khouzam at ericsson.com
Mon Mar 28 16:32:47 EDT 2011
Add a check in get online pids
Only sends the pids that are currently online.
Signed-off-by: Matthew Khouzam<matthew.khouzam at ericsson.com>
---
libustctl/libustctl.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/libustctl/libustctl.c b/libustctl/libustctl.c
index d57e645..9317440 100644
--- a/libustctl/libustctl.c
+++ b/libustctl/libustctl.c
@@ -92,6 +92,8 @@ pid_t *ustctl_get_online_pids(void)
{
struct dirent *dirent;
DIR *dir;
+ DIR *proc_dir;
+ char proc_dir_path[PATH_MAX];
unsigned int ret_size = 1 * sizeof(pid_t), i = 0;
dir = opendir(SOCK_DIR);
@@ -117,7 +119,17 @@ pid_t *ustctl_get_online_pids(void)
* We need to figure out an intelligent way of solving
* this, maybe connect-disconnect.
*/
- if (1) {
+ snprintf(proc_dir_path, PATH_MAX, "/proc/%u/", ret[i]);
+ proc_dir = opendir(proc_dir_path);
+ /*
+ * Note:
+ * maybe we should remove the empty dir in this pass
+ * too. Since the detection method is not perfect,
+ * this step is not yet implemented.
+ * A process can die, and its pid can be still taken
+ * when reading online pids.
+ */
+ if (proc_dir) {
ret_size += sizeof(pid_t);
ret = (pid_t *) realloc(ret, ret_size);
++i;
-- 1.7.0.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.casi.polymtl.ca/pipermail/lttng-dev/attachments/20110328/8c896e8d/attachment-0003.htm>
More information about the lttng-dev
mailing list