diff --git a/HISTORY.rst b/HISTORY.rst index 67e3a0935..3b00b3b9d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -40,6 +40,8 @@ XXXX-XX-XX pre-emptively checked for `Process.nice()`_ (set), `Process.ionice()`_, (set), `Process.cpu_affinity()`_ (set), `Process.rlimit()`_ (set), `Process.parent()`_. +- 2308_, [OpenBSD]: `Process.threads()`_ always fail with AccessDenied (also as + root). 5.9.5 ===== diff --git a/psutil/arch/openbsd/proc.c b/psutil/arch/openbsd/proc.c index 5c984fc53..96b85bc50 100644 --- a/psutil/arch/openbsd/proc.c +++ b/psutil/arch/openbsd/proc.c @@ -219,8 +219,15 @@ psutil_proc_threads(PyObject *self, PyObject *args) { kd = kvm_openfiles(0, 0, 0, O_RDONLY, errbuf); if (! kd) { - convert_kvm_err("kvm_openfiles()", errbuf); - goto error; + // Usually fails due to EPERM against /dev/mem. We retry with + // KVM_NO_FILES which apparently has the same effect. + // https://stackoverflow.com/questions/22369736/ + psutil_debug("kvm_openfiles(O_RDONLY) failed"); + kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf); + if (! kd) { + convert_kvm_err("kvm_openfiles()", errbuf); + goto error; + } } kp = kvm_getprocs(