ports/sysutils/py-psutil/patches/patch-psutil__psbsd_py

128 lines
4.1 KiB
Text
Raw Normal View History

Index: psutil/_psbsd.py
--- psutil/_psbsd.py.orig
+++ psutil/_psbsd.py
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""FreeBSD, OpenBSD and NetBSD platforms implementation."""
+"""FreeBSD, OpenBSD, SecBSD and NetBSD platforms implementation."""
import contextlib
import errno
@@ -19,6 +19,7 @@ from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from ._common import NETBSD
from ._common import OPENBSD
+from ._common import SECBSD
from ._common import AccessDenied
from ._common import NoSuchProcess
from ._common import ZombieProcess
@@ -52,7 +53,7 @@ if FREEBSD:
cext.SWAIT: _common.STATUS_WAITING,
cext.SLOCK: _common.STATUS_LOCKED,
}
-elif OPENBSD:
+elif OPENBSD or SECBSD:
PROC_STATUSES = {
cext.SIDL: _common.STATUS_IDLE,
cext.SSLEEP: _common.STATUS_SLEEPING,
@@ -281,7 +282,7 @@ def cpu_count_logical():
return cext.cpu_count_logical()
-if OPENBSD or NETBSD:
+if OPENBSD or SECBSD or NETBSD:
def cpu_count_cores():
# OpenBSD and NetBSD do not implement this.
@@ -339,7 +340,7 @@ def cpu_stats():
for line in f:
if line.startswith(b'intr'):
intrs = int(line.split()[1])
- elif OPENBSD:
+ elif OPENBSD or SECBSD:
# Note: the C ext is returning some metrics we are not exposing:
# traps, faults and forks.
ctxsw, intrs, soft_intrs, syscalls, traps, faults, forks = (
@@ -374,7 +375,7 @@ if FREEBSD:
ret.append(_common.scpufreq(current, min_freq, max_freq))
return ret
-elif OPENBSD:
+elif OPENBSD or SECBSD:
def cpu_freq():
curr = float(cext.cpu_freq())
@@ -450,7 +451,7 @@ def net_connections(kind):
families, types = conn_tmap[kind]
ret = set()
- if OPENBSD:
+ if OPENBSD or SECBSD:
rawlist = cext.net_connections(-1, families, types)
elif NETBSD:
rawlist = cext.net_connections(-1, kind)
@@ -525,7 +526,7 @@ def users():
for item in rawlist:
user, tty, hostname, tstamp, pid = item
if pid == -1:
- assert OPENBSD
+ assert SECBSD
pid = None
if tty == '~':
continue # reboot or shutdown
@@ -554,14 +555,14 @@ def _pid_0_exists():
def pids():
"""Returns a list of PIDs currently running on the system."""
ret = cext.pids()
- if OPENBSD and (0 not in ret) and _pid_0_exists():
+ if SECBSD and (0 not in ret) and _pid_0_exists():
# On OpenBSD the kernel does not return PID 0 (neither does
# ps) but it's actually querable (Process(0) will succeed).
ret.insert(0, 0)
return ret
-if OPENBSD or NETBSD:
+if OPENBSD or SECBSD or NETBSD:
def pid_exists(pid):
"""Return True if pid exists."""
@@ -690,7 +691,7 @@ class Process:
@wrap_exceptions
def cmdline(self):
- if OPENBSD and self.pid == 0:
+ if SECBSD and self.pid == 0:
return [] # ...else it crashes
elif NETBSD:
# XXX - most of the times the underlying sysctl() call on
@@ -808,7 +809,7 @@ class Process:
for thread_id, utime, stime in rawlist:
ntuple = _common.pthread(thread_id, utime, stime)
retlist.append(ntuple)
- if OPENBSD:
+ if SECBSD:
self._assert_alive()
return retlist
@@ -824,7 +825,7 @@ class Process:
if NETBSD:
rawlist = cext.net_connections(self.pid, kind)
- elif OPENBSD:
+ elif SECBSD:
rawlist = cext.net_connections(self.pid, families, types)
else:
rawlist = cext.proc_connections(self.pid, families, types)
@@ -875,7 +876,7 @@ class Process:
"""Return process current working directory."""
# sometimes we get an empty string, in which case we turn
# it into None
- if OPENBSD and self.pid == 0:
+ if SECBSD and self.pid == 0:
return "" # ...else it would raise EINVAL
elif NETBSD or HAS_PROC_OPEN_FILES:
# FreeBSD < 8 does not support functions based on