From 42ad5edf5ab162ddc0b9f0e3ad5eeb192dd95cf4 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Tue, 11 Jan 2022 09:44:13 +0100 Subject: [PATCH] BUILD(client): Plugin framework: Use KVM_PROC_ALL on NetBSD/OpenBSD kvm_getprocs(3) on Linux and FreeBSD (https://www.freebsd.org/cgi/man.cgi?kvm_getprocs) has ``` KERN_PROC_PROC all processes, without threads ... ``` OpenBSD (https://man.openbsd.org/kvm_getprocs.3) and NetBSD (https://man.openbsd.org/kvm_getprocs.3) however only know ``` KERN_PROC_KTHREAD all processes (user-level plus kernel threads) KERN_PROC_ALL all user-level processes ... ``` and ``` KERN_PROC_ALL all processes KERN_PROC_PID processes with process id arg ... ``` respectively, thus fall back to KERN_PROC_ALL where needed. Build-tested on OpenBSD 7.0-CURRENT. NB: The first hunk around kvm_openfiles(3) is from `clang-format`. (should've have happened in the commit introducing this line, I guess.) --- src/ProcessResolver.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ProcessResolver.cpp b/src/ProcessResolver.cpp index ebd26815da..cacf1ba3e2 100644 --- a/src/ProcessResolver.cpp +++ b/src/ProcessResolver.cpp @@ -239,7 +239,7 @@ void ProcessResolver::doResolve() { # ifdef KVM_NO_FILES kvm_t *kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, error); # else - kvm_t *kd = kvm_openfiles(NULL, _PATH_DEVNULL, NULL, O_RDONLY, error); + kvm_t *kd = kvm_openfiles(NULL, _PATH_DEVNULL, NULL, O_RDONLY, error); # endif if (!kd) { @@ -250,7 +250,11 @@ void ProcessResolver::doResolve() { } int n_procs; +# if defined(__NetBSD__) || defined(__OpenBSD__) + struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_procs); +# else struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_procs); +# endif if (!procs_info) { # ifndef QT_NO_DEBUG qCritical("ProcessResolver: kvm_getprocs() failed\n");