diff --git a/meson.build b/meson.build index 5ffa0cc..d36f644 100644 --- a/meson.build +++ b/meson.build @@ -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')) diff --git a/src/bin/system/process.c b/src/bin/system/process.c index 299da72..f533048 100644 --- a/src/bin/system/process.c +++ b/src/bin/system/process.c @@ -21,6 +21,10 @@ # include #endif +#if defined(__FreeBSD__) +#include +#endif + #if defined(__MacOS__) # include # include @@ -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;