* Matthew Khouzam ([email protected]) wrote:
> Signed-off-by: Matthew Khouzam <[email protected]>
> ---
>  libustctl/libustctl.c |   20 +++++++++++++++++++-
>  1 files changed, 19 insertions(+), 1 deletions(-)
> 
> diff --git a/libustctl/libustctl.c b/libustctl/libustctl.c
> index d57e645..b5a214b 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,11 +119,27 @@ 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:
> +                       * We should not remove the empty dir in this pass.
> +                       * A process can die, a new process can be born and
> +                       * assigned to that PID. the only way to avoid this
> +                       * would be to de-register and register centrally.
> +                       * Ltt-sessiond would be a good candidate for such a
> +                       * location.
> +                       */
> +                      if (proc_dir) {
> +                             /* We only needed to check if it's valid
> +                              * so we close it here
> +                              */
> +                             closedir(proc_dir);
>                               ret_size += sizeof(pid_t);
>                               ret = (pid_t *) realloc(ret, ret_size);
>                               ++i;
>                       }
> +     

Added whiteline and tab. Please fix (and double-check with checkpatch).

Thanks,

Mathieu
                
>               }
>       }
>  
> -- 
> 1.7.0.4
> 
> 
> _______________________________________________
> ltt-dev mailing list
> [email protected]
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
ltt-dev mailing list
[email protected]
http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev

Reply via email to