fbsd: nfiles.

Interesting.
This commit is contained in:
Alastair Poole 2021-02-26 08:33:07 +00:00
parent ceeb71c90a
commit 4a1c064972
2 changed files with 24 additions and 1 deletions

View File

@ -14,10 +14,14 @@ cc = meson.get_compiler('c')
deps = dependency('elementary', version: efl_version)
deps_os = declare_dependency(link_args : [] )
if host_os == 'openbsd' or host_os == 'freebsd' or host_os == 'dragonfly'
if host_os == 'openbsd' or host_os == 'dragonfly'
deps_os = declare_dependency(link_args : [ '-lkvm' ])
endif
if host_os == 'freebsd'
deps_os = declare_dependency(link_args : [ '-lkvm', '-lprocstat' ])
endif
##### dir locations
dir_prefix = get_option('prefix')
dir_bin = join_paths(dir_prefix, get_option('bindir'))

View File

@ -21,6 +21,10 @@
# include <sys/resource.h>
#endif
#if defined(__FreeBSD__)
#include <libprocstat.h>
#endif
#if defined(__MacOS__)
# include <libproc.h>
# include <sys/proc_info.h>
@ -910,6 +914,7 @@ _proc_thread_info(struct kinfo_proc *kp, Eina_Bool is_thread)
struct rusage *usage;
const char *state;
Proc_Info *p;
char buf[128];
static int pagesize = 0;
if (!pagesize) pagesize = getpagesize();
@ -949,6 +954,20 @@ _proc_thread_info(struct kinfo_proc *kp, Eina_Bool is_thread)
p->priority = kp->ki_pri.pri_level - PZERO;
p->numthreads = kp->ki_numthreads;
struct procstat *procstat = procstat_open_sysctl();
struct filestat *fst;
struct filestat_list *head, *next;
head = procstat_getfiles(procstat, kp, 0);
STAILQ_FOREACH(fst, head, next)
{
if (fst->fs_fd < 0) continue;
snprintf(buf, sizeof(buf), "%i", fst->fs_fd);
p->fds = eina_list_append(p->fds, strdup(buf));
}
p->numfiles = eina_list_count(p->fds);
procstat_freefiles(procstat, head);
p->tid = kp->ki_tid;
p->thread_name = strdup(kp->ki_tdname);
if (kp->ki_flag & P_KPROC) p->is_kernel = 1;