giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.11k stars 1.37k forks source link

[OpenBSD] Process.threads() fails with AccessDenied #2308

Closed giampaolo closed 9 months ago

giampaolo commented 9 months ago

Summary

Description

...also as a root user. Apparently this is due to /dev/mem having limited permissions, see: https://stackoverflow.com/questions/22369736/open-dev-mem-operation-not-permitted.

======================================================================
ERROR: psutil.tests.test_process.TestProcess.test_kill (proc=psutil.Process(pid=10182, status='terminated'), name='num_threads')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/vagrant/psutil/psutil/_psbsd.py", line 567, in wrapper
    return fun(self, *args, **kwargs)
  File "/vagrant/psutil/psutil/_psbsd.py", line 770, in threads
    rawlist = cext.proc_threads(self.pid)
PermissionError: [Errno 13] assume access denied (originated from (originated from kvm_openfiles(): /dev/mem: Permission denied))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/vagrant/psutil/psutil/tests/__init__.py", line 979, in assertProcessGone
    ret = fun()
  File "/vagrant/psutil/psutil/__init__.py", line 891, in num_threads
    return self._proc.num_threads()
  File "/vagrant/psutil/psutil/_psbsd.py", line 567, in wrapper
    return fun(self, *args, **kwargs)
  File "/vagrant/psutil/psutil/_psbsd.py", line 758, in num_threads
    return len(self.threads())
  File "/vagrant/psutil/psutil/_psbsd.py", line 574, in wrapper
    raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: (pid=10182)

======================================================================
ERROR: psutil.tests.test_process.TestProcess.test_kill (proc=psutil.Process(pid=10182, status='terminated'), name='threads')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/vagrant/psutil/psutil/_psbsd.py", line 567, in wrapper
    return fun(self, *args, **kwargs)
  File "/vagrant/psutil/psutil/_psbsd.py", line 770, in threads
    rawlist = cext.proc_threads(self.pid)
PermissionError: [Errno 13] assume access denied (originated from (originated from kvm_openfiles(): /dev/mem: Permission denied))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/vagrant/psutil/psutil/tests/__init__.py", line 979, in assertProcessGone
    ret = fun()
  File "/vagrant/psutil/psutil/__init__.py", line 901, in threads
    return self._proc.threads()
  File "/vagrant/psutil/psutil/_psbsd.py", line 574, in wrapper
    raise AccessDenied(self.pid, self._name)
psutil.AccessDenied: (pid=10182)