nfiles: not sure yet.

Could be useful.
This commit is contained in:
Alastair Poole 2021-02-27 19:11:19 +00:00
parent 0a65da0b1b
commit 1e2c64da2a
2 changed files with 18 additions and 11 deletions

View File

@ -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);
}

View File

@ -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);