Make libustctl list only online pids v3
[ust.git] / libustctl / libustctl.c
index 8b0dfc164c56bb9571a1202ed8f84d40ada3999b..4e6c495c6b744b5e8cb853a7309fbc0c6d908a44 100644 (file)
@@ -110,7 +110,7 @@ static int get_pids_in_dir(DIR *dir, pid_t **pid_list,
                            unsigned int *pid_list_size)
 {
        struct dirent *dirent;
-       long read_pid;
+       pid_t read_pid;
 
        while ((dirent = readdir(dir))) {
                if (!strcmp(dirent->d_name, ".") ||
@@ -121,21 +121,9 @@ static int get_pids_in_dir(DIR *dir, pid_t **pid_list,
                        continue;
                }
 
-               errno = 0;
-               read_pid = strtol(dirent->d_name, NULL, 10);
-               if (errno) {
-                       continue;
-               }
-
-               /*
-                * FIXME: Here we previously called pid_is_online, which
-                * always returned 1, now I replaced it with just 1.
-                * We need to figure out an intelligent way of solving
-                * this, maybe connect-disconnect.
-                */
-               if (1) {
+               if (ustcomm_is_socket_live(dirent->d_name, &read_pid)) {
 
-                       (*pid_list)[(*pid_list_index)++] = read_pid;
+                       (*pid_list)[(*pid_list_index)++] = (long) read_pid;
 
                        if (*pid_list_index == *pid_list_size) {
                                if (realloc_pid_list(pid_list, pid_list_size)) {
This page took 0.022666 seconds and 4 git commands to generate.