netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=1e2c64da2a4f109c1efb5085b5be328c92d08d37

commit 1e2c64da2a4f109c1efb5085b5be328c92d08d37
Author: Alastair Poole <nets...@gmail.com>
Date:   Sat Feb 27 19:11:19 2021 +0000

    nfiles: not sure yet.
    
    Could be useful.
---
 src/bin/system/process.c     | 21 ++++++++++++++-------
 src/bin/ui/ui_process_view.c |  8 ++++----
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/bin/system/process.c b/src/bin/system/process.c
index 8d4a5ed..6b3ec36 100644
--- a/src/bin/system/process.c
+++ b/src/bin/system/process.c
@@ -308,13 +308,20 @@ _stat(const char *path, Stat *st)
 static int
 _n_files(Proc_Info *p)
 {
-   char buf[4096];
+   char buf[256];
+   Eina_List *files;
+   char *f;
 
    snprintf(buf, sizeof(buf), "/proc/%d/fd", p->pid);
-   p->fds = ecore_file_ls(buf);
-   if (p->fds)
-     p->numfiles = eina_list_count(p->fds);
 
+   files = ecore_file_ls(buf);
+   EINA_LIST_FREE(files, f)
+     {
+        int *fd = malloc(sizeof(int));
+        *fd = atoi(f);
+        p->fds = eina_list_append(p->fds, fd);
+        p->numfiles++;
+     }
    return p->numfiles;
 }
 
@@ -1139,7 +1146,7 @@ void
 proc_info_free(Proc_Info *proc)
 {
    Proc_Info *t;
-   char *s;
+   int *i;
 
    if (!proc) return;
 
@@ -1153,8 +1160,8 @@ proc_info_free(Proc_Info *proc)
    if (proc->thread_name)
      free(proc->thread_name);
 
-   EINA_LIST_FREE(proc->fds, s)
-     free(s);
+   EINA_LIST_FREE(proc->fds, i)
+     free(i);
 
    free(proc);
 }
diff --git a/src/bin/ui/ui_process_view.c b/src/bin/ui/ui_process_view.c
index c09c2a4..520ffa0 100644
--- a/src/bin/ui/ui_process_view.c
+++ b/src/bin/ui/ui_process_view.c
@@ -840,7 +840,7 @@ _general_view_update(Ui_Data *pd, Proc_Info *proc)
 {
    struct passwd *pwd_entry;
    Eina_List *l;
-   char *s;
+   int *num;
 
    if (!strcmp(proc->state, "stop"))
      {
@@ -873,8 +873,8 @@ _general_view_update(Ui_Data *pd, Proc_Info *proc)
    elm_object_text_set(pd->general.entry_threads,
                        eina_slstr_printf("%d", proc->numthreads));
    Eina_Strbuf *b = eina_strbuf_new();
-   EINA_LIST_FOREACH(proc->fds, l, s)
-     eina_strbuf_append_printf(b, "%s ", s);
+   EINA_LIST_FOREACH(proc->fds, l, num)
+     eina_strbuf_append_printf(b, "%i ", *num);
    if (eina_strbuf_length_get(b))
      elm_object_text_set(pd->general.entry_files, eina_strbuf_string_get(b));
    eina_strbuf_free(b);
@@ -1127,7 +1127,7 @@ _general_tab_add(Evas_Object *parent, Ui_Data *pd)
    pd->general.entry_threads = entry = _entry_add(parent);
    elm_table_pack(tb, entry, 1, i++, 1, 1);
 
-   lb = _lb_add(parent, _("Files:"));
+   lb = _lb_add(parent, _("Open Files:"));
    elm_table_pack(tb, lb, 0, i, 1, 1);
    pd->general.entry_files = entry = _entry_add(parent);
    elm_table_pack(tb, entry, 1, i++, 1, 1);

-- 


Reply via email to