summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorryoon <ryoon@pkgsrc.org>2015-12-01 14:07:36 +0000
committerryoon <ryoon@pkgsrc.org>2015-12-01 14:07:36 +0000
commitdae0f51f32242dbae4d53f11901fd289a68abe63 (patch)
tree830209812ccf37f1405ff2958c39d8564e61801b
parentf662e57fc154e6a00f0e755ff23e344fe12eac3b (diff)
downloadpkgsrc-dae0f51f32242dbae4d53f11901fd289a68abe63.tar.gz
Update to 3.3.0
* Add preliminary NetBSD support code. It is sufficient to run letsencrypt python client on NetBSD. Changelog: 3.3.0 - 2015-11-25 ================== **Enhancements** - #558: [Linux] exposed psutil.PROCFS_PATH constant to change the default location of /proc filesystem. - #615: [OpenBSD] added OpenBSD support. (contributed by Landry Breuil) **Bug fixes** - #692: [UNIX] Process.name() is no longer cached as it may change. 3.2.2 - 2015-10-04 ================== **Bug fixes** - #517: [SunOS] net_io_counters failed to detect network interfaces correctly on Solaris 10 - #541: [FreeBSD] disk_io_counters r/w times were expressed in seconds instead of milliseconds. (patch by dasumin) - #610: [SunOS] fix build and tests on Solaris 10 - #623: [Linux] process or system connections raises ValueError if IPv6 is not supported by the system. - #678: [Linux] can't install psutil due to bug in setup.py. - #688: [Windows] compilation fails with MSVC 2015, Python 3.5. (patch by Mike Sarahan) 3.2.1 - 2015-09-03 ================== **Bug fixes** - #677: [Linux] can't install psutil due to bug in setup.py. 3.2.0 - 2015-09-02 ================== **Enhancements** - #644: [Windows] added support for CTRL_C_EVENT and CTRL_BREAK_EVENT signals to use with Process.send_signal(). - #648: CI test integration for OSX. (patch by Jeff Tang) - #663: [UNIX] net_if_addrs() now returns point-to-point (VPNs) addresses. - #655: [Windows] different issues regarding unicode handling were fixed. On Python 2 all APIs returning a string will now return an encoded version of it by using sys.getfilesystemencoding() codec. The APIs involved are: - psutil.net_if_addrs() - psutil.net_if_stats() - psutil.net_io_counters() - psutil.Process.cmdline() - psutil.Process.name() - psutil.Process.username() - psutil.users() **Bug fixes** - #513: [Linux] fixed integer overflow for RLIM_INFINITY. - #641: [Windows] fixed many compilation warnings. (patch by Jeff Tang) - #652: [Windows] net_if_addrs() UnicodeDecodeError in case of non-ASCII NIC names. - #655: [Windows] net_if_stats() UnicodeDecodeError in case of non-ASCII NIC names. - #659: [Linux] compilation error on Suse 10. (patch by maozguttman) - #664: [Linux] compilation error on Alpine Linux. (patch by Bart van Kleef) - #670: [Windows] segfgault of net_if_addrs() in case of non-ASCII NIC names. (patch by sk6249) - #672: [Windows] compilation fails if using Windows SDK v8.0. (patch by Steven Winfield) - #675: [Linux] net_connections(); UnicodeDecodeError may occur when listing UNIX sockets. 3.1.1 - 2015-07-15 ================== **Bug fixes** - #603: [Linux] ionice_set value range is incorrect. (patch by spacewander) - #645: [Linux] psutil.cpu_times_percent() may produce negative results. - #656: 'from psutil import *' does not work. 3.1.0 - 2015-07-15 ================== **Enhancements** - #534: [Linux] disk_partitions() added support for ZFS filesystems. - #646: continuous tests integration for Windows with https://ci.appveyor.com/project/giampaolo/psutil. - #647: new dev guide: https://github.com/giampaolo/psutil/blob/master/DEVGUIDE.rst - #651: continuous code quality test integration with https://scrutinizer-ci.com/g/giampaolo/psutil/ **Bug fixes** - #340: [Windows] Process.open_files() no longer hangs. Instead it uses a thred which times out and skips the file handle in case it's taking too long to be retrieved. (patch by Jeff Tang, PR #597) - #627: [Windows] Process.name() no longer raises AccessDenied for pids owned by another user. - #636: [Windows] Process.memory_info() raise AccessDenied. - #637: [UNIX] raise exception if trying to send signal to Process PID 0 as it will affect os.getpid()'s process group instead of PID 0. - #639: [Linux] Process.cmdline() can be truncated. - #640: [Linux] *connections functions may swallow errors and return an incomplete list of connnections. - #642: repr() of exceptions is incorrect. - #653: [Windows] Add inet_ntop function for Windows XP to support IPv6. - #641: [Windows] Replace deprecated string functions with safe equivalents. 3.0.1 - 2015-06-18 ================== **Bug fixes** - #632: [Linux] better error message if cannot parse process UNIX connections. - #634: [Linux] Proces.cmdline() does not include empty string arguments. - #635: [UNIX] crash on module import if 'enum' package is installed on python < 3.4. 3.0.0 - 2015-06-13 ================== **Enhancements** - #250: new psutil.net_if_stats() returning NIC statistics (isup, duplex, speed, MTU). - #376: new psutil.net_if_addrs() returning all NIC addresses a-la ifconfig. - #469: on Python >= 3.4 ``IOPRIO_CLASS_*`` and ``*_PRIORITY_CLASS`` constants returned by psutil.Process' ionice() and nice() methods are enums instead of plain integers. - #581: add .gitignore. (patch by Gabi Davar) - #582: connection constants returned by psutil.net_connections() and psutil.Process.connections() were turned from int to enums on Python > 3.4. - #587: Move native extension into the package. - #589: Process.cpu_affinity() accepts any kind of iterable (set, tuple, ...), not only lists. - #594: all deprecated APIs were removed. - #599: [Windows] process name() can now be determined for all processes even when running as a limited user. - #602: pre-commit GIT hook. - #629: enhanced support for py.test and nose test discovery and tests run. - #616: [Windows] Add inet_ntop function for Windows XP. **Bug fixes** - #428: [all UNIXes except Linux] correct handling of zombie processes; introduced new ZombieProcess exception class. - #512: [BSD] fix segfault in net_connections(). - #555: [Linux] psutil.users() correctly handles ":0" as an alias for "localhost" - #579: [Windows] Fixed open_files() for PID>64K. - #579: [Windows] fixed many compiler warnings. - #585: [FreeBSD] net_connections() may raise KeyError. - #586: [FreeBSD] cpu_affinity() segfaults on set in case an invalid CPU number is provided. - #593: [FreeBSD] Process().memory_maps() segfaults. - #606: Process.parent() may swallow NoSuchProcess exceptions. - #611: [SunOS] net_io_counters has send and received swapped - #614: [Linux]: cpu_count(logical=False) return the number of physical CPUs instead of physical cores. - #618: [SunOS] swap tests fail on Solaris when run as normal user - #628: [Linux] Process.name() truncates process name in case it contains spaces or parentheses. 2.2.1 - 2015-02-02 ================== **Bug fixes** - #496: [Linux] fix "ValueError: ambiguos inode with multiple PIDs references" (patch by Bruno Binet) 2.2.0 - 2015-01-06 ================== **Enhancements** - #521: drop support for Python 2.4 and 2.5. - #553: new examples/pstree.py script. - #564: C extension version mismatch in case the user messed up with psutil installation or with sys.path is now detected at import time. - #568: New examples/pidof.py script. - #569: [FreeBSD] add support for process CPU affinity. **Bug fixes** - #496: [Solaris] can't import psutil. - #547: [UNIX] Process.username() may raise KeyError if UID can't be resolved. - #551: [Windows] get rid of the unicode hack for net_io_counters() NIC names. - #556: [Linux] lots of file handles were left open. - #561: [Linux] net_connections() might skip some legitimate UNIX sockets. (patch by spacewander) - #565: [Windows] use proper encoding for psutil.Process.username() and psutil.users(). (patch by Sylvain Mouquet) - #567: [Linux] in the alternative implementation of CPU affinity PyList_Append and Py_BuildValue return values are not checked. - #569: [FreeBSD] fix memory leak in psutil.cpu_count(logical=False). - #571: [Linux] Process.open_files() might swallow AccessDenied exceptions and return an incomplete list of open files.
-rw-r--r--sysutils/py-psutil/Makefile13
-rw-r--r--sysutils/py-psutil/PLIST9
-rw-r--r--sysutils/py-psutil/distinfo28
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_____init____.py21
-rw-r--r--sysutils/py-psutil/patches/patch-psutil___psbsd.py94
-rw-r--r--sysutils/py-psutil/patches/patch-psutil___psnetbsd.py373
-rw-r--r--sysutils/py-psutil/patches/patch-psutil___psutil__bsd.c507
-rw-r--r--sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.c1314
-rw-r--r--sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.h57
-rw-r--r--sysutils/py-psutil/patches/patch-psutil___psutil__posix.c49
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.c670
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.h35
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.c540
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.h15
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.c296
-rw-r--r--sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.h23
-rw-r--r--sysutils/py-psutil/patches/patch-setup.py35
-rw-r--r--sysutils/py-psutil/patches/patch-test_test__psutil.py15
18 files changed, 1971 insertions, 2123 deletions
diff --git a/sysutils/py-psutil/Makefile b/sysutils/py-psutil/Makefile
index d2458bf07e8..6b42303990c 100644
--- a/sysutils/py-psutil/Makefile
+++ b/sysutils/py-psutil/Makefile
@@ -1,16 +1,19 @@
-# $NetBSD: Makefile,v 1.11 2015/01/24 23:23:48 adam Exp $
+# $NetBSD: Makefile,v 1.12 2015/12/01 14:07:36 ryoon Exp $
-DISTNAME= psutil-2.1.3
-PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
+DISTNAME= psutil-release-3.3.0
+PKGNAME= ${PYPKGPREFIX}-${DISTNAME:S/-release//}
CATEGORIES= sysutils
-MASTER_SITES= https://pypi.python.org/packages/source/p/psutil/
+MASTER_SITES= ${MASTER_SITE_GITHUB:=giampaolo/}
+GITHUB_PROJECT= psutil
+GITHUB_TAG= release-${PKGVERSION_NOREV}
MAINTAINER= pkgsrc-users@NetBSD.org
-HOMEPAGE= http://code.google.com/p/psutil/
+HOMEPAGE= https://github.com/giampaolo/psutil
COMMENT= Cross-platform process and system utilities module for Python
LICENSE= modified-bsd
REPLACE_PYTHON= psutil/*py
+EGG_NAME= psutil-${PKGVERSION}
.include "../../mk/bsd.prefs.mk"
diff --git a/sysutils/py-psutil/PLIST b/sysutils/py-psutil/PLIST
index a0ad6964892..78cc2adaf3c 100644
--- a/sysutils/py-psutil/PLIST
+++ b/sysutils/py-psutil/PLIST
@@ -1,6 +1,4 @@
-@comment $NetBSD: PLIST,v 1.5 2015/01/24 23:23:48 adam Exp $
-${PYSITELIB}/_psutil_${SYSTEM}.so
-${PYSITELIB}/_psutil_posix.so
+@comment $NetBSD: PLIST,v 1.6 2015/12/01 14:07:36 ryoon Exp $
${PYSITELIB}/${EGG_INFODIR}/PKG-INFO
${PYSITELIB}/${EGG_INFODIR}/SOURCES.txt
${PYSITELIB}/${EGG_INFODIR}/dependency_links.txt
@@ -20,9 +18,6 @@ ${PYSITELIB}/psutil/_psbsd.pyo
${PYSITELIB}/psutil/_pslinux.py
${PYSITELIB}/psutil/_pslinux.pyc
${PYSITELIB}/psutil/_pslinux.pyo
-${PYSITELIB}/psutil/_psnetbsd.py
-${PYSITELIB}/psutil/_psnetbsd.pyc
-${PYSITELIB}/psutil/_psnetbsd.pyo
${PYSITELIB}/psutil/_psosx.py
${PYSITELIB}/psutil/_psosx.pyc
${PYSITELIB}/psutil/_psosx.pyo
@@ -32,6 +27,8 @@ ${PYSITELIB}/psutil/_psposix.pyo
${PYSITELIB}/psutil/_pssunos.py
${PYSITELIB}/psutil/_pssunos.pyc
${PYSITELIB}/psutil/_pssunos.pyo
+${PYSITELIB}/psutil/_psutil_bsd.so
+${PYSITELIB}/psutil/_psutil_posix.so
${PYSITELIB}/psutil/_pswindows.py
${PYSITELIB}/psutil/_pswindows.pyc
${PYSITELIB}/psutil/_pswindows.pyo
diff --git a/sysutils/py-psutil/distinfo b/sysutils/py-psutil/distinfo
index 729141329b7..33d1aa0dcbc 100644
--- a/sysutils/py-psutil/distinfo
+++ b/sysutils/py-psutil/distinfo
@@ -1,14 +1,16 @@
-$NetBSD: distinfo,v 1.9 2015/11/04 01:32:27 agc Exp $
+$NetBSD: distinfo,v 1.10 2015/12/01 14:07:36 ryoon Exp $
-SHA1 (psutil-2.1.3.tar.gz) = aae4725eb33cf56d4480bc60f50c147870d607ba
-RMD160 (psutil-2.1.3.tar.gz) = 4d5d0971c7acbd81cd883eceb237b688a60d3b80
-SHA512 (psutil-2.1.3.tar.gz) = 12a566c2c53897d858bd75455da8f52d9d9279e28dc0df40594275626f75da716d82c8f67d1fc37df4bd3bc05fef401391cb6c52380c819d1e82fb4edd11f843
-Size (psutil-2.1.3.tar.gz) = 224008 bytes
-SHA1 (patch-psutil_____init____.py) = 4036989d048542eb2b5649c6398146369d2793a5
-SHA1 (patch-psutil___psnetbsd.py) = 1a017104b6ac800de1a47ccb810d5a56b2bde66a
-SHA1 (patch-psutil___psutil__netbsd.c) = 00480e009800bb1970592c8bcfbef17d7ac79240
-SHA1 (patch-psutil___psutil__netbsd.h) = 33e3c857f764d8391db747068ade7ea333698ec0
-SHA1 (patch-psutil_arch_netbsd_process__info.c) = c384d12cc47514d6396d779d59c586ef2b42a89a
-SHA1 (patch-psutil_arch_netbsd_process__info.h) = b23075df15749e4e5274ccb9e21d67ac55fdd199
-SHA1 (patch-setup.py) = 3e87561b6dfd7e851e232342dab3b2e8ade28cfd
-SHA1 (patch-test_test__psutil.py) = c521f4fa30b24cb86115370e52979c2c7f7af4a3
+SHA1 (psutil-release-3.3.0.tar.gz) = e1a1ff558a90ad48302ad4aaf485a1841d67ee89
+RMD160 (psutil-release-3.3.0.tar.gz) = 59ddfcdd2bdaa4274ff22e40da021c0ff69191a1
+SHA512 (psutil-release-3.3.0.tar.gz) = c0865631a3cb3a347c5e24328108f05a84f9468f661ca864764df3e5a723a52e38b338a3126b870c7f3a54fbbae60e6e4d80dba54f9b5459edb08fd24d078da3
+Size (psutil-release-3.3.0.tar.gz) = 256632 bytes
+SHA1 (patch-psutil_____init____.py) = 40b3108ab934ed8529a3989eda331d9d2cf2b7af
+SHA1 (patch-psutil___psbsd.py) = e80fd4dcfad88468963d67c90b79c09625c43d1c
+SHA1 (patch-psutil___psutil__bsd.c) = 4efa4ae9fcd16961e3bca987726732260214b635
+SHA1 (patch-psutil___psutil__posix.c) = 6a01a7d45481ab1f512ef90164548a8a8b5cb831
+SHA1 (patch-psutil_arch_bsd_netbsd.c) = 2613cc24b9c25469d67bac3bc30b09d3e391919f
+SHA1 (patch-psutil_arch_bsd_netbsd.h) = 4d58a458b10e34e4fac862cc70e53b9faf65dcb0
+SHA1 (patch-psutil_arch_bsd_netbsd__socks.c) = f02ef45768ba34ede2ace38901ee59a15b817537
+SHA1 (patch-psutil_arch_bsd_netbsd__socks.h) = a0af0fe10b7d5243cfc89cb23a863fd819b6cfcc
+SHA1 (patch-setup.py) = daf3e4ebed119a234387d5b37cf693bbf8156a5d
+SHA1 (patch-test_test__psutil.py) = fee930410be0e083b5f616f41f30f6687ab224d9
diff --git a/sysutils/py-psutil/patches/patch-psutil_____init____.py b/sysutils/py-psutil/patches/patch-psutil_____init____.py
index 3a39595dc23..6c0dc002cab 100644
--- a/sysutils/py-psutil/patches/patch-psutil_____init____.py
+++ b/sysutils/py-psutil/patches/patch-psutil_____init____.py
@@ -1,16 +1,13 @@
-$NetBSD: patch-psutil_____init____.py,v 1.2 2014/10/01 11:53:33 wiz Exp $
+$NetBSD: patch-psutil_____init____.py,v 1.3 2015/12/01 14:07:36 ryoon Exp $
-Port to NetBSD.
-
---- psutil/__init__.py.orig 2014-07-15 15:23:11.000000000 +0000
+--- psutil/__init__.py.orig 2015-11-25 01:20:34.000000000 +0000
+++ psutil/__init__.py
-@@ -150,6 +150,9 @@ elif sys.platform.startswith("darwin"):
- elif sys.platform.startswith("freebsd"):
- import psutil._psbsd as _psplatform
+@@ -122,7 +122,7 @@ elif sys.platform.startswith("win32"):
+ elif sys.platform.startswith("darwin"):
+ from . import _psosx as _psplatform
+
+-elif sys.platform.startswith("freebsd") or sys.platform.startswith("openbsd"):
++elif sys.platform.startswith("freebsd") or sys.platform.startswith("openbsd") or sys.platform.startswith("netbsd"):
+ from . import _psbsd as _psplatform
-+elif sys.platform.startswith("netbsd"):
-+ import psutil._psnetbsd as _psplatform
-+
elif sys.platform.startswith("sunos"):
- import psutil._pssunos as _psplatform
- from psutil._pssunos import (CONN_IDLE, # NOQA
diff --git a/sysutils/py-psutil/patches/patch-psutil___psbsd.py b/sysutils/py-psutil/patches/patch-psutil___psbsd.py
new file mode 100644
index 00000000000..619b88870b6
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil___psbsd.py
@@ -0,0 +1,94 @@
+$NetBSD: patch-psutil___psbsd.py,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/_psbsd.py.orig 2015-11-25 01:20:34.000000000 +0000
++++ psutil/_psbsd.py
+@@ -28,6 +28,7 @@ __extra__all__ = []
+
+ FREEBSD = sys.platform.startswith("freebsd")
+ OPENBSD = sys.platform.startswith("openbsd")
++NETBSD = sys.platform.startswith("netbsd")
+
+ if FREEBSD:
+ PROC_STATUSES = {
+@@ -60,6 +61,15 @@ elif OPENBSD:
+ cext.SRUN: _common.STATUS_WAKING,
+ cext.SONPROC: _common.STATUS_RUNNING,
+ }
++elif NETBSD:
++ PROC_STATUSES = {
++ cext.SIDL: _common.STATUS_IDLE,
++ cext.SACTIVE: _common.STATUS_RUNNING,
++ cext.SDYING: _common.STATUS_ZOMBIE,
++ cext.SSTOP: _common.STATUS_STOPPED,
++ cext.SZOMB: _common.STATUS_ZOMBIE,
++ cext.SDEAD: _common.STATUS_DEAD,
++ }
+
+ TCP_STATUSES = {
+ cext.TCPS_ESTABLISHED: _common.CONN_ESTABLISHED,
+@@ -76,7 +86,10 @@ TCP_STATUSES = {
+ cext.PSUTIL_CONN_NONE: _common.CONN_NONE,
+ }
+
+-PAGESIZE = os.sysconf("SC_PAGE_SIZE")
++if NETBSD:
++ PAGESIZE = os.sysconf("SC_PAGESIZE")
++else:
++ PAGESIZE = os.sysconf("SC_PAGE_SIZE")
+ AF_LINK = cext_posix.AF_LINK
+
+ # extend base mem ntuple with BSD-specific memory metrics
+@@ -156,9 +169,9 @@ def cpu_count_logical():
+ return cext.cpu_count_logical()
+
+
+-if OPENBSD:
++if OPENBSD or NETBSD:
+ def cpu_count_physical():
+- # OpenBSD does not implement this.
++ # OpenBSD and NetBSD do not implement this.
+ return 1 if cpu_count_logical() == 1 else None
+ else:
+ def cpu_count_physical():
+@@ -273,7 +286,7 @@ def net_if_stats():
+ return ret
+
+
+-if OPENBSD:
++if OPENBSD or NETBSD:
+ def pid_exists(pid):
+ exists = _psposix.pid_exists(pid)
+ if not exists:
+@@ -333,7 +346,7 @@ class Process(object):
+
+ @wrap_exceptions
+ def exe(self):
+- if FREEBSD:
++ if FREEBSD or NETBSD:
+ return cext.proc_exe(self.pid)
+ else:
+ # exe cannot be determined on OpenBSD; references:
+@@ -423,6 +436,23 @@ class Process(object):
+
+ @wrap_exceptions
+ def connections(self, kind='inet'):
++ if NETBSD:
++ families, types = conn_tmap[kind]
++ ret = set()
++ rawlist = cext.proc_connections(self.pid)
++ for item in rawlist:
++ fd, fam, type, laddr, raddr, status = item
++ if fam in families and type in types:
++ try:
++ status = TCP_STATUSES[status]
++ except KeyError:
++ status = TCP_STATUSES[cext.PSUTIL_CONN_NONE]
++ fam = sockfam_to_enum(fam)
++ type = socktype_to_enum(type)
++ nt = _common.pconn(fd, fam, type, laddr, raddr, status)
++ ret.add(nt)
++ return list(ret)
++
+ if kind not in conn_tmap:
+ raise ValueError("invalid %r kind argument; choose between %s"
+ % (kind, ', '.join([repr(x) for x in conn_tmap])))
diff --git a/sysutils/py-psutil/patches/patch-psutil___psnetbsd.py b/sysutils/py-psutil/patches/patch-psutil___psnetbsd.py
deleted file mode 100644
index 42d2e284981..00000000000
--- a/sysutils/py-psutil/patches/patch-psutil___psnetbsd.py
+++ /dev/null
@@ -1,373 +0,0 @@
-$NetBSD: patch-psutil___psnetbsd.py,v 1.2 2015/01/24 23:01:29 adam Exp $
-
-Port to NetBSD.
-
---- psutil/_psnetbsd.py.orig 2013-10-12 13:19:29.000000000 +0000
-+++ psutil/_psnetbsd.py
-@@ -0,0 +1,366 @@
-+#!/usr/bin/env python
-+
-+# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
-+# Use of this source code is governed by a BSD-style license that can be
-+# found in the LICENSE file.
-+
-+"""NetBSD platform implementation."""
-+
-+import errno
-+import os
-+import sys
-+import warnings
-+
-+import _psutil_netbsd
-+import _psutil_posix
-+from psutil import _psposix
-+from psutil._compat import namedtuple, wraps
-+from psutil._common import *
-+
-+__extra__all__ = []
-+
-+# --- constants
-+
-+# Since these constants get determined at import time we do not want to
-+# crash immediately; instead we'll set them to None and most likely
-+# we'll crash later as they're used for determining process CPU stats
-+# and creation_time
-+try:
-+ NUM_CPUS = _psutil_netbsd.get_num_cpus()
-+except Exception:
-+ NUM_CPUS = None
-+ warnings.warn("couldn't determine platform's NUM_CPUS", RuntimeWarning)
-+try:
-+ TOTAL_PHYMEM = _psutil_netbsd.get_virtual_mem()[0]
-+except Exception:
-+ TOTAL_PHYMEM = None
-+ warnings.warn("couldn't determine platform's TOTAL_PHYMEM", RuntimeWarning)
-+try:
-+ BOOT_TIME = _psutil_netbsd.get_system_boot_time()
-+except Exception:
-+ BOOT_TIME = None
-+ warnings.warn("couldn't determine platform's BOOT_TIME", RuntimeWarning)
-+
-+
-+_PAGESIZE = os.sysconf("SC_PAGE_SIZE")
-+_cputimes_ntuple = namedtuple('cputimes', 'user nice system idle irq')
-+
-+# --- public functions
-+
-+get_system_boot_time = _psutil_netbsd.get_system_boot_time
-+
-+nt_virtmem_info = namedtuple('vmem', ' '.join([
-+ # all platforms
-+ 'total', 'available', 'percent', 'used', 'free',
-+ # *BSD specific
-+ 'active',
-+ 'inactive',
-+ 'shared',
-+ 'wired']))
-+
-+def virtual_memory():
-+ """System virtual memory as a namedutple."""
-+ mem = _psutil_netbsd.get_virtual_mem()
-+ total, free, active, inactive, wired, shared = mem
-+ avail = inactive + free
-+ used = active + wired
-+ percent = usage_percent((total - avail), total, _round=1)
-+ return nt_virtmem_info(total, avail, percent, used, free,
-+ active, inactive, shared, wired)
-+
-+def swap_memory():
-+ """System swap memory as (total, used, free, sin, sout) namedtuple."""
-+ total, used, free, sin, sout = \
-+ [x * _PAGESIZE for x in _psutil_netbsd.get_swap_mem()]
-+ percent = usage_percent(used, total, _round=1)
-+ return nt_swapmeminfo(total, used, free, percent, sin, sout)
-+
-+def cpu_times():
-+ """Return system per-CPU times as a named tuple"""
-+ user, nice, system, idle, irq = _psutil_netbsd.get_system_cpu_times()
-+ return _cputimes_ntuple(user, nice, system, idle, irq)
-+
-+def per_cpu_times():
-+ """Return system CPU times as a named tuple"""
-+ ret = []
-+ for cpu_t in _psutil_netbsd.get_system_per_cpu_times():
-+ user, nice, system, idle, irq = cpu_t
-+ item = _cputimes_ntuple(user, nice, system, idle, irq)
-+ ret.append(item)
-+ return ret
-+
-+# \todo: check this
-+# XXX
-+# Ok, this is very dirty.
-+# On FreeBSD < 8 we cannot gather per-cpu information, see:
-+# http://code.google.com/p/psutil/issues/detail?id=226
-+# If NUM_CPUS > 1, on first call we return single cpu times to avoid a
-+# crash at psutil import time.
-+# Next calls will fail with NotImplementedError
-+if not hasattr(_psutil_netbsd, "get_system_per_cpu_times"):
-+ def per_cpu_times():
-+ if NUM_CPUS == 1:
-+ return [get_system_cpu_times]
-+ if per_cpu_times.__called__:
-+ raise NotImplementedError("supported only starting from FreeBSD 8")
-+ per_cpu_times.__called__ = True
-+ return [get_system_cpu_times]
-+per_cpu_times.__called__ = False
-+
-+def disk_partitions(all=False):
-+ retlist = []
-+ partitions = _psutil_netbsd.get_disk_partitions()
-+ for partition in partitions:
-+ device, mountpoint, fstype, opts = partition
-+ if device == 'none':
-+ device = ''
-+ if not all:
-+ if not os.path.isabs(device) \
-+ or not os.path.exists(device):
-+ continue
-+ ntuple = nt_partition(device, mountpoint, fstype, opts)
-+ retlist.append(ntuple)
-+ return retlist
-+
-+def get_system_users():
-+ retlist = []
-+ rawlist = _psutil_netbsd.get_system_users()
-+ for item in rawlist:
-+ user, tty, hostname, tstamp = item
-+ if tty == '~':
-+ continue # reboot or shutdown
-+ nt = nt_user(user, tty or None, hostname, tstamp)
-+ retlist.append(nt)
-+ return retlist
-+
-+get_pid_list = _psutil_netbsd.get_pid_list
-+pid_exists = _psposix.pid_exists
-+disk_usage = _psposix.disk_usage
-+net_io_counters = _psutil_netbsd.get_net_io_counters
-+disk_io_counters = _psutil_netbsd.get_disk_io_counters
-+
-+
-+def wrap_exceptions(fun):
-+ """Decorator which translates bare OSError exceptions into
-+ NoSuchProcess and AccessDenied.
-+ """
-+ @wraps(fun)
-+ def wrapper(self, *args, **kwargs):
-+ try:
-+ return fun(self, *args, **kwargs)
-+ except OSError:
-+ err = sys.exc_info()[1]
-+ if err.errno == errno.ESRCH:
-+ raise NoSuchProcess(self.pid, self._process_name)
-+ if err.errno in (errno.EPERM, errno.EACCES):
-+ raise AccessDenied(self.pid, self._process_name)
-+ raise
-+ return wrapper
-+
-+_status_map = {
-+ _psutil_netbsd.SSTOP : STATUS_STOPPED,
-+ _psutil_netbsd.SIDL : STATUS_IDLE,
-+ _psutil_netbsd.SACTIVE : STATUS_RUNNING,
-+# \todo: to what to map this?
-+# _psutil_netbsd.SDYING : STATUS_IDLE,
-+ _psutil_netbsd.SDEAD : STATUS_DEAD,
-+ _psutil_netbsd.SZOMB : STATUS_ZOMBIE,
-+}
-+
-+_conn_status_map = {_psutil_netbsd.TCPS_ESTABLISHED : CONN_ESTABLISHED,
-+ _psutil_netbsd.TCPS_SYN_SENT : CONN_SYN_SENT,
-+ _psutil_netbsd.TCPS_SYN_RECEIVED : CONN_SYN_RECV,
-+ _psutil_netbsd.TCPS_FIN_WAIT_1 : CONN_FIN_WAIT1,
-+ _psutil_netbsd.TCPS_FIN_WAIT_2 : CONN_FIN_WAIT2,
-+ _psutil_netbsd.TCPS_TIME_WAIT : CONN_TIME_WAIT,
-+ _psutil_netbsd.TCPS_CLOSED : CONN_CLOSE,
-+ _psutil_netbsd.TCPS_CLOSE_WAIT : CONN_CLOSE_WAIT,
-+ _psutil_netbsd.TCPS_LAST_ACK : CONN_LAST_ACK,
-+ _psutil_netbsd.TCPS_LISTEN : CONN_LISTEN,
-+ _psutil_netbsd.TCPS_CLOSING : CONN_CLOSING,
-+ }
-+
-+
-+class Process(object):
-+ """Wrapper class around underlying C implementation."""
-+
-+ __slots__ = ["pid", "_process_name"]
-+
-+ def __init__(self, pid):
-+ self.pid = pid
-+ self._process_name = None
-+
-+ @wrap_exceptions
-+ def get_process_name(self):
-+ """Return process name as a string of limited len (15)."""
-+ return _psutil_netbsd.get_process_name(self.pid)
-+
-+ @wrap_exceptions
-+ def get_process_exe(self):
-+ """Return process executable pathname."""
-+ return _psutil_netbsd.get_process_exe(self.pid)
-+
-+ @wrap_exceptions
-+ def get_process_cmdline(self):
-+ """Return process cmdline as a list of arguments."""
-+ return _psutil_netbsd.get_process_cmdline(self.pid)
-+
-+ @wrap_exceptions
-+ def get_process_terminal(self):
-+ tty_nr = _psutil_netbsd.get_process_tty_nr(self.pid)
-+ tmap = _psposix._get_terminal_map()
-+ try:
-+ return tmap[tty_nr]
-+ except KeyError:
-+ return None
-+
-+ @wrap_exceptions
-+ def get_process_ppid(self):
-+ """Return process parent pid."""
-+ return _psutil_netbsd.get_process_ppid(self.pid)
-+
-+ # XXX - available on FreeBSD >= 8 only
-+ if hasattr(_psutil_netbsd, "get_process_cwd"):
-+ @wrap_exceptions
-+ def get_process_cwd(self):
-+ """Return process current working directory."""
-+ # sometimes we get an empty string, in which case we turn
-+ # it into None
-+ return _psutil_netbsd.get_process_cwd(self.pid) or None
-+
-+ @wrap_exceptions
-+ def get_process_uids(self):
-+ """Return real, effective and saved user ids."""
-+ real, effective, saved = _psutil_netbsd.get_process_uids(self.pid)
-+ return nt_uids(real, effective, saved)
-+
-+ @wrap_exceptions
-+ def get_process_gids(self):
-+ """Return real, effective and saved group ids."""
-+ real, effective, saved = _psutil_netbsd.get_process_gids(self.pid)
-+ return nt_gids(real, effective, saved)
-+
-+ @wrap_exceptions
-+ def get_cpu_times(self):
-+ """return a tuple containing process user/kernel time."""
-+ user, system = _psutil_netbsd.get_process_cpu_times(self.pid)
-+ return nt_cputimes(user, system)
-+
-+ @wrap_exceptions
-+ def get_memory_info(self):
-+ """Return a tuple with the process' RSS and VMS size."""
-+ rss, vms = _psutil_netbsd.get_process_memory_info(self.pid)[:2]
-+ return nt_meminfo(rss, vms)
-+
-+ _nt_ext_mem = namedtuple('meminfo', 'rss vms text data stack')
-+
-+ @wrap_exceptions
-+ def get_ext_memory_info(self):
-+ return self._nt_ext_mem(*_psutil_netbsd.get_process_memory_info(self.pid))
-+
-+ @wrap_exceptions
-+ def get_process_create_time(self):
-+ """Return the start time of the process as a number of seconds since
-+ the epoch."""
-+ return _psutil_netbsd.get_process_create_time(self.pid)
-+
-+ @wrap_exceptions
-+ def get_process_num_threads(self):
-+ """Return the number of threads belonging to the process."""
-+ return _psutil_netbsd.get_process_num_threads(self.pid)
-+
-+ @wrap_exceptions
-+ def get_num_ctx_switches(self):
-+ return nt_ctxsw(*_psutil_netbsd.get_process_num_ctx_switches(self.pid))
-+
-+ @wrap_exceptions
-+ def get_num_fds(self):
-+ """Return the number of file descriptors opened by this process."""
-+ return _psutil_netbsd.get_process_num_fds(self.pid)
-+
-+ @wrap_exceptions
-+ def get_process_threads(self):
-+ """Return the number of threads belonging to the process."""
-+ rawlist = _psutil_netbsd.get_process_threads(self.pid)
-+ retlist = []
-+ for thread_id, utime, stime in rawlist:
-+ ntuple = nt_thread(thread_id, utime, stime)
-+ retlist.append(ntuple)
-+ return retlist
-+
-+ @wrap_exceptions
-+ def get_open_files(self):
-+ """Return files opened by process as a list of namedtuples."""
-+ # XXX - C implementation available on FreeBSD >= 8 only
-+ # else fallback on lsof parser
-+ if hasattr(_psutil_netbsd, "get_process_open_files"):
-+ rawlist = _psutil_netbsd.get_process_open_files(self.pid)
-+ return [nt_openfile(path, fd) for path, fd in rawlist]
-+ else:
-+ lsof = _psposix.LsofParser(self.pid, self._process_name)
-+ return lsof.get_process_open_files()
-+
-+ @wrap_exceptions
-+ def get_connections(self, kind='inet'):
-+ """Return etwork connections opened by a process as a list of
-+ namedtuples.
-+ """
-+ if kind not in conn_tmap:
-+ raise ValueError("invalid %r kind argument; choose between %s"
-+ % (kind, ', '.join([repr(x) for x in conn_tmap])))
-+ families, types = conn_tmap[kind]
-+ rawlist = _psutil_netbsd.get_process_connections(self.pid, families,
-+ types)
-+ ret = []
-+ for item in rawlist:
-+ fd, fam, type, laddr, raddr, status = item
-+ status = _conn_status_map[status]
-+ nt = nt_connection(fd, fam, type, laddr, raddr, status)
-+ ret.append(nt)
-+ return ret
-+
-+ @wrap_exceptions
-+ def process_wait(self, timeout=None):
-+ try:
-+ return _psposix.wait_pid(self.pid, timeout)
-+ except TimeoutExpired:
-+ raise TimeoutExpired(self.pid, self._process_name)
-+
-+ @wrap_exceptions
-+ def get_process_nice(self):
-+ return _psutil_posix.getpriority(self.pid)
-+
-+ @wrap_exceptions
-+ def set_process_nice(self, value):
-+ return _psutil_posix.setpriority(self.pid, value)
-+
-+ @wrap_exceptions
-+ def get_process_status(self):
-+ code = _psutil_netbsd.get_process_status(self.pid)
-+ if code in _status_map:
-+ return _status_map[code]
-+ # XXX is this legit? will we even ever get here?
-+ return "?"
-+
-+ @wrap_exceptions
-+ def get_process_io_counters(self):
-+ rc, wc, rb, wb = _psutil_netbsd.get_process_io_counters(self.pid)
-+ return nt_io(rc, wc, rb, wb)
-+
-+ nt_mmap_grouped = namedtuple('mmap',
-+ 'path rss, private, ref_count, shadow_count')
-+ nt_mmap_ext = namedtuple('mmap',
-+ 'addr, perms path rss, private, ref_count, shadow_count')
-+
-+ @wrap_exceptions
-+ def get_memory_maps(self):
-+ return _psutil_netbsd.get_process_memory_maps(self.pid)
-+
-+ # FreeBSD < 8 does not support kinfo_getfile() and kinfo_getvmmap()
-+ if not hasattr(_psutil_netbsd, 'get_process_open_files'):
-+ def _not_implemented(self):
-+ raise NotImplementedError("supported only starting from FreeBSD 8")
-+ get_open_files = _not_implemented
-+ get_process_cwd = _not_implemented
-+ get_memory_maps = _not_implemented
-+ get_num_fds = _not_implemented
diff --git a/sysutils/py-psutil/patches/patch-psutil___psutil__bsd.c b/sysutils/py-psutil/patches/patch-psutil___psutil__bsd.c
new file mode 100644
index 00000000000..864cd5b3ca4
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil___psutil__bsd.c
@@ -0,0 +1,507 @@
+$NetBSD: patch-psutil___psutil__bsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/_psutil_bsd.c.orig 2015-11-25 01:20:34.000000000 +0000
++++ psutil/_psutil_bsd.c
+@@ -15,6 +15,9 @@
+ * - psutil.Process.memory_maps()
+ */
+
++#if defined(__NetBSD__)
++#define _KMEMUSER
++#endif
+
+ #include <Python.h>
+ #include <assert.h>
+@@ -42,6 +45,7 @@
+ #include <netinet/in_pcb.h>
+ #include <netinet/tcp.h>
+ #include <netinet/tcp_timer.h>
++#include <netinet/ip_var.h>
+ #include <netinet/tcp_var.h> // for struct xtcpcb
+ #include <netinet/tcp_fsm.h> // for TCP connection states
+ #include <arpa/inet.h> // for inet_ntop()
+@@ -63,6 +67,9 @@
+ #include "arch/bsd/freebsd_socks.h"
+ #elif __OpenBSD__
+ #include "arch/bsd/openbsd.h"
++#elif __NetBSD__
++ #include "arch/bsd/netbsd.h"
++ #include "arch/bsd/netbsd_socks.h"
+ #endif
+
+ #ifdef __FreeBSD__
+@@ -85,6 +92,15 @@
+ #include <sys/sched.h> // for CPUSTATES & CP_*
+ #endif
+
++#if defined(__NetBSD__)
++ #include <utmpx.h>
++ #include <sys/vnode.h> // for VREG
++ #include <sys/sched.h> // for CPUSTATES & CP_*
++#define _KERNEL
++ #include <uvm/uvm_extern.h>
++#undef _KERNEL
++#endif
++
+
+ // convert a timeval struct to a double
+ #define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0)
+@@ -95,7 +111,7 @@
+ (uint32_t) (bt.frac >> 32) ) >> 32 ) / 1000000)
+ #endif
+
+-#ifdef __OpenBSD__
++#if defined(__OpenBSD__) || defined (__NetBSD__)
+ #define PSUTIL_KPT2DOUBLE(t) (t ## _sec + t ## _usec / 1000000.0)
+ #endif
+
+@@ -125,7 +141,7 @@ psutil_pids(PyObject *self, PyObject *ar
+ for (idx = 0; idx < num_processes; idx++) {
+ #ifdef __FreeBSD__
+ py_pid = Py_BuildValue("i", proclist->ki_pid);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ py_pid = Py_BuildValue("i", proclist->p_pid);
+ #endif
+ if (!py_pid)
+@@ -174,14 +190,14 @@ psutil_boot_time(PyObject *self, PyObjec
+ static PyObject *
+ psutil_proc_name(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+ return NULL;
+ #ifdef __FreeBSD__
+ return Py_BuildValue("s", kp.ki_comm);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ return Py_BuildValue("s", kp.p_comm);
+ #endif
+ }
+@@ -213,14 +229,14 @@ psutil_proc_cmdline(PyObject *self, PyOb
+ static PyObject *
+ psutil_proc_ppid(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+ return NULL;
+ #ifdef __FreeBSD__
+ return Py_BuildValue("l", (long)kp.ki_ppid);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ return Py_BuildValue("l", (long)kp.p_ppid);
+ #endif
+ }
+@@ -232,14 +248,14 @@ psutil_proc_ppid(PyObject *self, PyObjec
+ static PyObject *
+ psutil_proc_status(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+ return NULL;
+ #ifdef __FreeBSD__
+ return Py_BuildValue("i", (int)kp.ki_stat);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ return Py_BuildValue("i", (int)kp.p_stat);
+ #endif
+ }
+@@ -252,7 +268,7 @@ psutil_proc_status(PyObject *self, PyObj
+ static PyObject *
+ psutil_proc_uids(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+@@ -262,7 +278,7 @@ psutil_proc_uids(PyObject *self, PyObjec
+ (long)kp.ki_ruid,
+ (long)kp.ki_uid,
+ (long)kp.ki_svuid);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ (long)kp.p_ruid,
+ (long)kp.p_uid,
+ (long)kp.p_svuid);
+@@ -277,7 +293,7 @@ psutil_proc_uids(PyObject *self, PyObjec
+ static PyObject *
+ psutil_proc_gids(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+@@ -287,7 +303,7 @@ psutil_proc_gids(PyObject *self, PyObjec
+ (long)kp.ki_rgid,
+ (long)kp.ki_groups[0],
+ (long)kp.ki_svuid);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ (long)kp.p_rgid,
+ (long)kp.p_groups[0],
+ (long)kp.p_svuid);
+@@ -302,14 +318,14 @@ psutil_proc_gids(PyObject *self, PyObjec
+ static PyObject *
+ psutil_proc_tty_nr(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+ return NULL;
+ #ifdef __FreeBSD__
+ return Py_BuildValue("i", kp.ki_tdev);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ return Py_BuildValue("i", kp.p_tdev);
+ #endif
+ }
+@@ -321,7 +337,7 @@ psutil_proc_tty_nr(PyObject *self, PyObj
+ static PyObject *
+ psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+@@ -330,7 +346,7 @@ psutil_proc_num_ctx_switches(PyObject *s
+ #ifdef __FreeBSD__
+ kp.ki_rusage.ru_nvcsw,
+ kp.ki_rusage.ru_nivcsw);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ kp.p_uru_nvcsw,
+ kp.p_uru_nivcsw);
+ #endif
+@@ -344,7 +360,7 @@ static PyObject *
+ psutil_proc_cpu_times(PyObject *self, PyObject *args) {
+ long pid;
+ double user_t, sys_t;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+@@ -353,7 +369,7 @@ psutil_proc_cpu_times(PyObject *self, Py
+ #ifdef __FreeBSD__
+ user_t = PSUTIL_TV2DOUBLE(kp.ki_rusage.ru_utime);
+ sys_t = PSUTIL_TV2DOUBLE(kp.ki_rusage.ru_stime);
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ user_t = PSUTIL_KPT2DOUBLE(kp.p_uutime);
+ sys_t = PSUTIL_KPT2DOUBLE(kp.p_ustime);
+ #endif
+@@ -389,14 +405,14 @@ psutil_cpu_count_logical(PyObject *self,
+ static PyObject *
+ psutil_proc_create_time(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+ return NULL;
+ #ifdef __FreeBSD__
+ return Py_BuildValue("d", PSUTIL_TV2DOUBLE(kp.ki_start));
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ return Py_BuildValue("d", PSUTIL_KPT2DOUBLE(kp.p_ustart));
+ #endif
+ }
+@@ -409,7 +425,7 @@ psutil_proc_create_time(PyObject *self,
+ static PyObject *
+ psutil_proc_io_counters(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+@@ -419,7 +435,7 @@ psutil_proc_io_counters(PyObject *self,
+ #ifdef __FreeBSD__
+ kp.ki_rusage.ru_inblock,
+ kp.ki_rusage.ru_oublock,
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ kp.p_uru_inblock,
+ kp.p_uru_oublock,
+ #endif
+@@ -438,7 +454,7 @@ psutil_proc_io_counters(PyObject *self,
+ static PyObject *
+ psutil_proc_memory_info(PyObject *self, PyObject *args) {
+ long pid;
+- struct kinfo_proc kp;
++ kinfo_proc kp;
+ if (! PyArg_ParseTuple(args, "l", &pid))
+ return NULL;
+ if (psutil_kinfo_proc(pid, &kp) == -1)
+@@ -451,7 +467,7 @@ psutil_proc_memory_info(PyObject *self,
+ ptoa(kp.ki_tsize), // text
+ ptoa(kp.ki_dsize), // data
+ ptoa(kp.ki_ssize)); // stack
+-#elif __OpenBSD__
++#elif defined(__OpenBSD__)
+ ptoa(kp.p_vm_rssize), // rss
+ // vms, this is how ps does it, see:
+ // http://anoncvs.spacehopper.org/openbsd-src/tree/bin/ps/print.c#n461
+@@ -459,6 +475,9 @@ psutil_proc_memory_info(PyObject *self,
+ ptoa(kp.p_vm_tsize), // text
+ ptoa(kp.p_vm_dsize), // data
+ ptoa(kp.p_vm_ssize)); // stack
++#else
++/* not implemented */
++ 0, 0, 0, 0, 0);
+ #endif
+ }
+
+@@ -472,7 +491,7 @@ psutil_cpu_times(PyObject *self, PyObjec
+ size_t size = sizeof(cpu_time);
+ int ret;
+
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ ret = sysctlbyname("kern.cp_time", &cpu_time, &size, NULL, 0);
+ #elif __OpenBSD__
+ int mib[] = {CTL_KERN, KERN_CPTIME};
+@@ -499,14 +518,14 @@ psutil_cpu_times(PyObject *self, PyObjec
+ * utility has the same problem see:
+ * https://github.com/giampaolo/psutil/issues/595
+ */
+-#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 || __OpenBSD__
++#if (defined(__FreeBSD_version) && __FreeBSD_version >= 800000) || __OpenBSD__ || defined(__NetBSD__)
+ static PyObject *
+ psutil_proc_open_files(PyObject *self, PyObject *args) {
+ long pid;
+ int i, cnt;
+ struct kinfo_file *freep = NULL;
+ struct kinfo_file *kif;
+- struct kinfo_proc kipp;
++ kinfo_proc kipp;
+ PyObject *py_retlist = PyList_New(0);
+ PyObject *py_tuple = NULL;
+
+@@ -530,11 +549,16 @@ psutil_proc_open_files(PyObject *self, P
+ (kif->kf_vnode_type == KF_VTYPE_VREG))
+ {
+ py_tuple = Py_BuildValue("(si)", kif->kf_path, kif->kf_fd);
+-#else
++#elif defined(__OpenBSD__)
+ if ((kif->f_type == DTYPE_VNODE) &&
+ (kif->v_type == VREG))
+ {
+ py_tuple = Py_BuildValue("(si)", "", kif->fd_fd);
++#elif defined(__NetBSD__)
++ if ((kif->ki_ftype == DTYPE_VNODE) &&
++ (kif->ki_vtype == VREG))
++ {
++ py_tuple = Py_BuildValue("(si)", "", kif->ki_fd);
+ #endif
+ if (py_tuple == NULL)
+ goto error;
+@@ -567,7 +591,11 @@ psutil_disk_partitions(PyObject *self, P
+ long len;
+ uint64_t flags;
+ char opts[200];
++#if defined(__NetBSD__)
++ struct statvfs *fs = NULL;
++#else
+ struct statfs *fs = NULL;
++#endif
+ PyObject *py_retlist = PyList_New(0);
+ PyObject *py_tuple = NULL;
+
+@@ -576,7 +604,11 @@ psutil_disk_partitions(PyObject *self, P
+
+ // get the number of mount points
+ Py_BEGIN_ALLOW_THREADS
++#if defined(__NetBSD__)
++ num = getvfsstat(NULL, 0, MNT_NOWAIT);
++#else
+ num = getfsstat(NULL, 0, MNT_NOWAIT);
++#endif
+ Py_END_ALLOW_THREADS
+ if (num == -1) {
+ PyErr_SetFromErrno(PyExc_OSError);
+@@ -591,7 +623,11 @@ psutil_disk_partitions(PyObject *self, P
+ }
+
+ Py_BEGIN_ALLOW_THREADS
++#if defined(__NetBSD__)
++ num = getvfsstat(fs, len, MNT_NOWAIT);
++#else
+ num = getfsstat(fs, len, MNT_NOWAIT);
++#endif
+ Py_END_ALLOW_THREADS
+ if (num == -1) {
+ PyErr_SetFromErrno(PyExc_OSError);
+@@ -601,24 +637,32 @@ psutil_disk_partitions(PyObject *self, P
+ for (i = 0; i < num; i++) {
+ py_tuple = NULL;
+ opts[0] = 0;
++#if defined(__NetBSD__)
++ flags = fs[i].f_flag;
++#else
+ flags = fs[i].f_flags;
++#endif
+
+ // see sys/mount.h
+ if (flags & MNT_RDONLY)
+ strlcat(opts, "ro", sizeof(opts));
+ else
+ strlcat(opts, "rw", sizeof(opts));
+-#ifdef __FreeBSD__
+ if (flags & MNT_SYNCHRONOUS)
+ strlcat(opts, ",sync", sizeof(opts));
+ if (flags & MNT_NOEXEC)
+ strlcat(opts, ",noexec", sizeof(opts));
+ if (flags & MNT_NOSUID)
+ strlcat(opts, ",nosuid", sizeof(opts));
+- if (flags & MNT_UNION)
+- strlcat(opts, ",union", sizeof(opts));
+ if (flags & MNT_ASYNC)
+ strlcat(opts, ",async", sizeof(opts));
++ if (flags & MNT_NOATIME)
++ strlcat(opts, ",noatime", sizeof(opts));
++ if (flags & MNT_SOFTDEP)
++ strlcat(opts, ",softdep", sizeof(opts));
++#ifdef __FreeBSD__
++ if (flags & MNT_UNION)
++ strlcat(opts, ",union", sizeof(opts));
+ if (flags & MNT_SUIDDIR)
+ strlcat(opts, ",suiddir", sizeof(opts));
+ if (flags & MNT_SOFTDEP)
+@@ -631,27 +675,33 @@ psutil_disk_partitions(PyObject *self, P
+ strlcat(opts, ",multilabel", sizeof(opts));
+ if (flags & MNT_ACLS)
+ strlcat(opts, ",acls", sizeof(opts));
+- if (flags & MNT_NOATIME)
+- strlcat(opts, ",noatime", sizeof(opts));
+ if (flags & MNT_NOCLUSTERR)
+ strlcat(opts, ",noclusterr", sizeof(opts));
+ if (flags & MNT_NOCLUSTERW)
+ strlcat(opts, ",noclusterw", sizeof(opts));
+ if (flags & MNT_NFS4ACLS)
+ strlcat(opts, ",nfs4acls", sizeof(opts));
+-#elif __OpenBSD__
+- if (flags & MNT_SYNCHRONOUS)
+- strlcat(opts, ",sync", sizeof(opts));
+- if (flags & MNT_NOEXEC)
+- strlcat(opts, ",noexec", sizeof(opts));
+- if (flags & MNT_NOSUID)
+- strlcat(opts, ",nosuid", sizeof(opts));
+- if (flags & MNT_ASYNC)
+- strlcat(opts, ",async", sizeof(opts));
+- if (flags & MNT_SOFTDEP)
+- strlcat(opts, ",softdep", sizeof(opts));
+- if (flags & MNT_NOATIME)
+- strlcat(opts, ",noatime", sizeof(opts));
++#elif __NetBSD__
++ if (flags & MNT_NODEV)
++ strlcat(opts, ",nodev", sizeof(opts));
++ if (flags & MNT_UNION)
++ strlcat(opts, ",union", sizeof(opts));
++ if (flags & MNT_NOCOREDUMP)
++ strlcat(opts, ",nocoredump", sizeof(opts));
++ if (flags & MNT_RELATIME)
++ strlcat(opts, ",relatime", sizeof(opts));
++ if (flags & MNT_IGNORE)
++ strlcat(opts, ",ignore", sizeof(opts));
++ if (flags & MNT_DISCARD)
++ strlcat(opts, ",discard", sizeof(opts));
++ if (flags & MNT_EXTATTR)
++ strlcat(opts, ",extattr", sizeof(opts));
++ if (flags & MNT_LOG)
++ strlcat(opts, ",log", sizeof(opts));
++ if (flags & MNT_SYMPERM)
++ strlcat(opts, ",symperm", sizeof(opts));
++ if (flags & MNT_NODEVMTIME)
++ strlcat(opts, ",nodevmtime", sizeof(opts));
+ #endif
+ py_tuple = Py_BuildValue("(ssss)",
+ fs[i].f_mntfromname, // device
+@@ -778,7 +828,7 @@ psutil_users(PyObject *self, PyObject *a
+ if (py_retlist == NULL)
+ return NULL;
+
+-#if __FreeBSD_version < 900000 || __OpenBSD__
++#if (defined(__FreeBSD_version) && (__FreeBSD_version < 900000)) || __OpenBSD__
+ struct utmp ut;
+ FILE *fp;
+
+@@ -812,6 +862,7 @@ psutil_users(PyObject *self, PyObject *a
+ #else
+ struct utmpx *utx;
+
++ setutxent();
+ while ((utx = getutxent()) != NULL) {
+ if (utx->ut_type != USER_PROCESS)
+ continue;
+@@ -883,20 +934,21 @@ PsutilMethods[] = {
+ "Return process tty (terminal) number"},
+ {"proc_cwd", psutil_proc_cwd, METH_VARARGS,
+ "Return process current working directory."},
+-#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 || __OpenBSD__
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 || __OpenBSD__ || defined(__NetBSD__)
+ {"proc_num_fds", psutil_proc_num_fds, METH_VARARGS,
+ "Return the number of file descriptors opened by this process"},
+ #endif
+-#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 || __OpenBSD__
++#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000 || __OpenBSD__ || defined(__NetBSD__)
+ {"proc_open_files", psutil_proc_open_files, METH_VARARGS,
+ "Return files opened by process as a list of (path, fd) tuples"},
+ #endif
+
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ {"proc_exe", psutil_proc_exe, METH_VARARGS,
+ "Return process pathname executable"},
+ {"proc_num_threads", psutil_proc_num_threads, METH_VARARGS,
+ "Return number of threads used by process"},
++#if defined(__FreeBSD__)
+ {"proc_memory_maps", psutil_proc_memory_maps, METH_VARARGS,
+ "Return a list of tuples for every process's memory map"},
+ {"proc_cpu_affinity_get", psutil_proc_cpu_affinity_get, METH_VARARGS,
+@@ -906,6 +958,7 @@ PsutilMethods[] = {
+ {"cpu_count_phys", psutil_cpu_count_phys, METH_VARARGS,
+ "Return an XML string to determine the number physical CPUs."},
+ #endif
++#endif
+
+ // --- system-related functions
+
+@@ -932,7 +985,7 @@ PsutilMethods[] = {
+ "Return a Python dict of tuples for disk I/O information"},
+ {"users", psutil_users, METH_VARARGS,
+ "Return currently connected users as a list of tuples"},
+-#ifdef __FreeBSD__
++#if defined(__FreeBSD__) || defined(__NetBSD__)
+ {"net_connections", psutil_net_connections, METH_VARARGS,
+ "Return system-wide open connections."},
+ #endif
+@@ -1010,6 +1063,13 @@ void init_psutil_bsd(void)
+ PyModule_AddIntConstant(module, "SZOMB", SZOMB); // unused
+ PyModule_AddIntConstant(module, "SDEAD", SDEAD);
+ PyModule_AddIntConstant(module, "SONPROC", SONPROC);
++#elif defined(__NetBSD__)
++ PyModule_AddIntConstant(module, "SIDL", SIDL);
++ PyModule_AddIntConstant(module, "SACTIVE", SACTIVE);
++ PyModule_AddIntConstant(module, "SDYING", SDYING);
++ PyModule_AddIntConstant(module, "SSTOP", SSTOP);
++ PyModule_AddIntConstant(module, "SZOMB", SZOMB);
++ PyModule_AddIntConstant(module, "SDEAD", SDEAD);
+ #endif
+
+ // connection status constants
diff --git a/sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.c b/sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.c
deleted file mode 100644
index 28f212a2241..00000000000
--- a/sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.c
+++ /dev/null
@@ -1,1314 +0,0 @@
-$NetBSD: patch-psutil___psutil__netbsd.c,v 1.2 2015/01/24 23:01:29 adam Exp $
-
-Port to NetBSD.
-
---- psutil/_psutil_netbsd.c.orig 2013-10-12 13:19:29.000000000 +0000
-+++ psutil/_psutil_netbsd.c
-@@ -0,0 +1,1307 @@
-+/*
-+ * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
-+ * Use of this source code is governed by a BSD-style license that can be
-+ * found in the LICENSE file.
-+ *
-+ * NetBSD platform-specific module methods for _psutil_netbsd
-+ */
-+
-+
-+#include <Python.h>
-+#include <assert.h>
-+#include <errno.h>
-+#include <stdlib.h>
-+#include <stdio.h>
-+#include <signal.h>
-+#include <fcntl.h>
-+#include <paths.h>
-+#include <sys/types.h>
-+#define _KMEMUSER 1 /* needed on NetBSD to get kprocinfo structs */
-+#include <sys/sysctl.h>
-+#include <sys/param.h>
-+#include <sys/user.h>
-+#include <sys/proc.h>
-+#include <sys/file.h>
-+#include <net/route.h>
-+
-+#include <sys/socket.h>
-+#include <sys/socketvar.h> /* for struct xsocket */
-+/* for xinpcb struct */
-+#include <netinet/in.h>
-+#include <netinet/in_systm.h>
-+#include <netinet/ip.h>
-+#include <netinet/in_pcb.h>
-+#include <netinet/tcp.h> /* for tcp_seq type */
-+#include <netinet/ip_var.h> /* for struct ipqehead */
-+#include <netinet/tcp_timer.h> /* for TCPT_NTIMERS */
-+#include <netinet/tcp_var.h> /* for struct xtcpcb */
-+#include <netinet/tcp_fsm.h> /* for TCP connection states */
-+#include <arpa/inet.h> /* for inet_ntop() */
-+
-+#include <utmpx.h>
-+#include <kvm.h>
-+#include <util.h>
-+#include <sys/vmmeter.h> /* needed for vmtotal struct */
-+#include <sys/mount.h>
-+
-+#include <net/if.h> /* net io counters */
-+#include <net/if_dl.h>
-+#include <net/route.h>
-+
-+#include <netinet/in.h> /* process open files/connections */
-+#include <sys/un.h>
-+
-+#include <stdbool.h>
-+
-+#include "_psutil_netbsd.h"
-+#include "_psutil_common.h"
-+#include "arch/bsd/process_info.h"
-+
-+#define STIME(k) ((k)->p_ustime_sec + (k)->p_ustime_usec/1000000.0)
-+#define UTIME(k) ((k)->p_uutime_sec + (k)->p_uutime_usec/1000000.0)
-+
-+#if !defined(KERN_PROC_INC_THREAD)
-+#define KERN_PROC_INC_THREAD 0
-+#endif
-+
-+/* Determine whether and where procfs is mounted. */
-+static bool
-+psutil_find_procfs(char *buffer, size_t buffer_size)
-+{
-+ int num, i;
-+ struct statvfs *mntbuf;
-+
-+ num = getmntinfo(&mntbuf, 0);
-+ if (num == 0) {
-+ return false;
-+ }
-+
-+ for (i = 0; i < num; i++) {
-+ if (strcmp(mntbuf[i].f_fstypename, "procfs") == 0) {
-+ (void)strlcpy(buffer, mntbuf[i].f_mntonname, buffer_size);
-+ return true;
-+ }
-+ }
-+
-+ errno = ENOENT;
-+ return false;
-+}
-+
-+/*
-+ * Utility function which fills a struct kinfo_proc2 struct based on process pid
-+ */
-+static int
-+psutil_get_kinfo_proc(const pid_t pid, struct kinfo_proc2 *proc)
-+{
-+ int mib[4];
-+ size_t size;
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC2;
-+ mib[2] = KERN_PROC_PID;
-+ mib[3] = pid;
-+
-+ size = sizeof(struct kinfo_proc2);
-+
-+ if (sysctl((int*)mib, 4, proc, &size, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return -1;
-+ }
-+
-+ /*
-+ * sysctl stores 0 in the size if we can't find the process information.
-+ */
-+ if (size == 0) {
-+ NoSuchProcess();
-+ return -1;
-+ }
-+ return 0;
-+}
-+
-+static int
-+psutil_get_pagesize(void)
-+{
-+ int mib[2];
-+ int pagesize;
-+ size_t size;
-+ mib[0] = CTL_HW;
-+ mib[1] = HW_PAGESIZE;
-+
-+ size = sizeof(int);
-+
-+ if (sysctl((int*)mib, 2, &pagesize, &size, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return -1;
-+ }
-+
-+ return pagesize;
-+}
-+
-+
-+/*
-+ * Return a Python list of all the PIDs running on the system.
-+ */
-+static PyObject*
-+get_pid_list(PyObject* self, PyObject* args)
-+{
-+ struct kinfo_proc2 *proclist = NULL;
-+ struct kinfo_proc2 *orig_address = NULL;
-+ size_t num_processes;
-+ size_t idx;
-+ PyObject* retlist = PyList_New(0);
-+ PyObject* pid = NULL;
-+
-+ if (retlist == NULL) {
-+ return NULL;
-+ }
-+ if (psutil_get_proc_list(&proclist, &num_processes) != 0) {
-+ PyErr_SetString(PyExc_RuntimeError, "failed to retrieve process list.");
-+ goto error;
-+ }
-+
-+ if (num_processes > 0) {
-+ orig_address = proclist; // save so we can free it after we're done
-+ for (idx=0; idx < num_processes; idx++) {
-+ pid = Py_BuildValue("i", proclist->p_pid);
-+ if (!pid)
-+ goto error;
-+ if (PyList_Append(retlist, pid))
-+ goto error;
-+ Py_DECREF(pid);
-+ proclist++;
-+ }
-+ free(orig_address);
-+ }
-+
-+ return retlist;
-+
-+error:
-+ Py_XDECREF(pid);
-+ Py_DECREF(retlist);
-+ if (orig_address != NULL) {
-+ free(orig_address);
-+ }
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python float indicating the system boot time expressed in
-+ * seconds since the epoch.
-+ */
-+static PyObject*
-+get_system_boot_time(PyObject* self, PyObject* args)
-+{
-+ /* fetch sysctl "kern.boottime" */
-+ static int request[2] = { CTL_KERN, KERN_BOOTTIME };
-+ struct timeval boottime;
-+ size_t len = sizeof(boottime);
-+
-+ if (sysctl(request, 2, &boottime, &len, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+ }
-+ return Py_BuildValue("d", (double)boottime.tv_sec);
-+}
-+
-+
-+/*
-+ * Return process name from struct kinfo_proc2 as a Python string.
-+ */
-+static PyObject*
-+get_process_name(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("s", kp.p_comm);
-+}
-+
-+
-+/*
-+ * Return process pathname executable.
-+ * Thanks to Robert N. M. Watson:
-+ * http://fxr.googlebit.com/source/usr.bin/procstat/procstat_bin.c?v=8-CURRENT
-+ */
-+static PyObject*
-+get_process_exe(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ char procfs[PATH_MAX], exelink[PATH_MAX], pathname[PATH_MAX];
-+ ssize_t len;
-+
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ PyErr_BadArgument();
-+ return NULL;
-+ }
-+
-+ /* Is procfs mounted? */
-+ if (! psutil_find_procfs(procfs, sizeof(procfs))) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+ }
-+
-+ /* Get the name of the executable from procfs. */
-+ (void)snprintf(exelink, sizeof(exelink), "%s/%ld/exe", procfs, pid);
-+ len = readlink(exelink, pathname, sizeof(pathname) - 1);
-+ if (len == - 1) {
-+ if (errno == ENOENT) {
-+ return NoSuchProcess();
-+ } else {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+ }
-+ }
-+ pathname[len] = '\0';
-+
-+ /*
-+ * Does the link point to "/"? In this case procfs doesn't know where
-+ * the executable is.
-+ */
-+ if (strcmp(pathname, "/") == 0) {
-+ errno = ENOENT;
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+ }
-+
-+ return Py_BuildValue("s", pathname);
-+}
-+
-+
-+/*
-+ * Return process cmdline as a Python list of cmdline arguments.
-+ */
-+static PyObject*
-+get_process_cmdline(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ PyObject* arglist = NULL;
-+
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+
-+ // get the commandline, defined in arch/bsd/process_info.c
-+ arglist = psutil_get_arg_list(pid);
-+
-+ // psutil_get_arg_list() returns NULL only if psutil_get_cmd_args failed with ESRCH
-+ // (no process with that PID)
-+ if (NULL == arglist) {
-+ return PyErr_SetFromErrno(PyExc_OSError);
-+ }
-+ return Py_BuildValue("N", arglist);
-+}
-+
-+
-+/*
-+ * Return process parent pid from struct kinfo_proc2 as a Python integer.
-+ */
-+static PyObject*
-+get_process_ppid(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("l", (long)kp.p_ppid);
-+}
-+
-+
-+/*
-+ * Return process status as a Python integer.
-+ */
-+static PyObject*
-+get_process_status(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("i", (int)kp.p_stat);
-+}
-+
-+
-+/*
-+ * Return process real, effective and saved user ids from struct kinfo_proc2
-+ * as a Python tuple.
-+ */
-+static PyObject*
-+get_process_uids(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("lll", (long)kp.p_ruid,
-+ (long)kp.p_uid,
-+ (long)kp.p_svuid);
-+}
-+
-+
-+/*
-+ * Return process real, effective and saved group ids from struct kinfo_proc2
-+ * as a Python tuple.
-+ */
-+static PyObject*
-+get_process_gids(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("lll", (long)kp.p_rgid,
-+ (long)kp.p_groups[0],
-+ (long)kp.p_svuid);
-+}
-+
-+
-+/*
-+ * Return process real, effective and saved group ids from struct kinfo_proc2
-+ * as a Python tuple.
-+ */
-+static PyObject*
-+get_process_tty_nr(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("i", kp.p_tdev);
-+}
-+
-+
-+/*
-+ * Return the number of context switches performed by process as a tuple.
-+ */
-+static PyObject*
-+get_process_num_ctx_switches(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("(ll)", kp.p_uru_nvcsw,
-+ kp.p_uru_nivcsw);
-+}
-+
-+
-+
-+/*
-+ * Return number of threads used by process as a Python integer.
-+ */
-+static PyObject*
-+get_process_num_threads(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ return Py_BuildValue("l", (long)kp.p_nlwps);
-+}
-+
-+
-+/*
-+ * Retrieves all threads used by process returning a list of tuples
-+ * including thread id, user time and system time.
-+ * Thanks to Robert N. M. Watson:
-+ * http://fxr.googlebit.com/source/usr.bin/procstat/procstat_threads.c?v=8-CURRENT
-+ */
-+static PyObject*
-+get_process_threads(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ int mib[4];
-+ struct kinfo_proc2 *kip = NULL;
-+ struct kinfo_proc2 *kipp = NULL;
-+ int error;
-+ unsigned int i;
-+ size_t size;
-+ PyObject* retList = PyList_New(0);
-+ PyObject* pyTuple = NULL;
-+
-+ if (retList == NULL)
-+ return NULL;
-+ if (! PyArg_ParseTuple(args, "l", &pid))
-+ goto error;
-+
-+ /*
-+ * We need to re-query for thread information, so don't use *kipp.
-+ */
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
-+ mib[3] = pid;
-+
-+ size = 0;
-+ error = sysctl(mib, 4, NULL, &size, NULL, 0);
-+ if (error == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+ if (size == 0) {
-+ NoSuchProcess();
-+ goto error;
-+ }
-+
-+ kip = malloc(size);
-+ if (kip == NULL) {
-+ PyErr_NoMemory();
-+ goto error;
-+ }
-+
-+ error = sysctl(mib, 4, kip, &size, NULL, 0);
-+ if (error == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+ if (size == 0) {
-+ NoSuchProcess();
-+ goto error;
-+ }
-+
-+ for (i = 0; i < size / sizeof(*kipp); i++) {
-+ kipp = &kip[i];
-+ pyTuple = Py_BuildValue("Idd",
-+ /** \todo: unsupported? */
-+ 0, // kipp->ki_tid
-+ UTIME(kipp),
-+ STIME(kipp)
-+ );
-+ if (pyTuple == NULL)
-+ goto error;
-+ if (PyList_Append(retList, pyTuple))
-+ goto error;
-+ Py_DECREF(pyTuple);
-+ }
-+ free(kip);
-+
-+ return retList;
-+
-+error:
-+ Py_XDECREF(pyTuple);
-+ Py_DECREF(retList);
-+ if (kip != NULL) {
-+ free(kip);
-+ }
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python tuple (user_time, kernel_time)
-+ */
-+static PyObject*
-+get_process_cpu_times(PyObject* self, PyObject* args)
-+{
-+ long pid;
-+ double user_t, sys_t;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ // convert from microseconds to seconds
-+ user_t = UTIME(&kp);
-+ sys_t = STIME(&kp);
-+ return Py_BuildValue("(dd)", user_t, sys_t);
-+}
-+
-+
-+/*
-+ * Return a Python integer indicating the number of CPUs on the system
-+ */
-+static PyObject*
-+get_num_cpus(PyObject* self, PyObject* args)
-+{
-+ int mib[2];
-+ int ncpu;
-+ size_t len;
-+
-+ mib[0] = CTL_HW;
-+ mib[1] = HW_NCPU;
-+ len = sizeof(ncpu);
-+
-+ if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+ }
-+
-+ return Py_BuildValue("i", ncpu);
-+}
-+
-+
-+/*
-+ * Return a Python float indicating the process create time expressed in
-+ * seconds since the epoch.
-+ */
-+static PyObject*
-+get_process_create_time(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python float indicating the process create time expressed in
-+ * seconds since the epoch.
-+ */
-+static PyObject*
-+get_process_io_counters(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return extended memory info for a process as a Python tuple.
-+ */
-+static PyObject*
-+get_process_memory_info(PyObject* self, PyObject* args)
-+{
-+ int pagesize;
-+ long pid;
-+ struct kinfo_proc2 kp;
-+ if (! PyArg_ParseTuple(args, "l", &pid)) {
-+ return NULL;
-+ }
-+ if (psutil_get_kinfo_proc(pid, &kp) == -1) {
-+ return NULL;
-+ }
-+ pagesize = psutil_get_pagesize();
-+
-+ /** \todo: find replacement for kp.ki_size */
-+ return Py_BuildValue("(lllll)", kp.p_vm_rssize * pagesize, // rss
-+ 0, //vms(long)kp.ki_size, // vms
-+ kp.p_vm_tsize * pagesize, // text
-+ kp.p_vm_dsize * pagesize, // data
-+ kp.p_vm_ssize * pagesize); // stack
-+}
-+
-+
-+/*
-+ * Return virtual memory usage statistics.
-+ */
-+static PyObject*
-+get_virtual_mem(PyObject* self, PyObject* args)
-+{
-+ int mib[2];
-+ struct uvmexp_sysctl uvmexp;
-+ size_t size;
-+ struct vmtotal vm;
-+ int64_t pagesize;
-+
-+ mib[0] = CTL_VM;
-+ mib[1] = VM_UVMEXP2;
-+ size = sizeof(uvmexp);
-+ if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0)
-+ goto error;
-+
-+ mib[0] = CTL_VM;
-+ mib[1] = VM_METER;
-+ size = sizeof(vm);
-+ if (sysctl(mib, 2, &vm, &size, NULL, 0) != 0)
-+ goto error;
-+
-+ pagesize = uvmexp.pagesize;
-+ return Py_BuildValue("KKKKKK",
-+ uvmexp.npages * pagesize,
-+ uvmexp.free * pagesize,
-+ uvmexp.active * pagesize,
-+ uvmexp.inactive * pagesize,
-+ uvmexp.wired * pagesize,
-+ (vm.t_vmshr + vm.t_rmshr) * pagesize // shared
-+ );
-+
-+error:
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return swap memory stats (see 'swapinfo' cmdline tool)
-+ */
-+static PyObject*
-+get_swap_mem(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement; see sbin/swapctl/swaplist.c for possible example code */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python tuple representing user, kernel and idle CPU times
-+ */
-+static PyObject*
-+get_system_cpu_times(PyObject* self, PyObject* args)
-+{
-+ long cpu_time[CPUSTATES];
-+ size_t size;
-+
-+ size = sizeof(cpu_time);
-+
-+ if (sysctlbyname("kern.cp_time", &cpu_time, &size, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ return NULL;
-+ }
-+
-+ return Py_BuildValue("(ddddd)",
-+ (double)cpu_time[CP_USER] / CLOCKS_PER_SEC,
-+ (double)cpu_time[CP_NICE] / CLOCKS_PER_SEC,
-+ (double)cpu_time[CP_SYS] / CLOCKS_PER_SEC,
-+ (double)cpu_time[CP_IDLE] / CLOCKS_PER_SEC,
-+ (double)cpu_time[CP_INTR] / CLOCKS_PER_SEC
-+ );
-+}
-+
-+/*
-+ * Return files opened by process as a list of (path, fd) tuples
-+ */
-+static PyObject*
-+get_process_open_files(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return files opened by process as a list of (path, fd) tuples
-+ */
-+static PyObject*
-+get_process_num_fds(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return process current working directory.
-+ */
-+static PyObject*
-+get_process_cwd(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+static char *
-+psutil_fetch_tcplist(void)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+static int
-+psutil_sockaddr_port(int family, struct sockaddr_storage *ss)
-+{
-+ struct sockaddr_in6 *sin6;
-+ struct sockaddr_in *sin;
-+
-+ if (family == AF_INET) {
-+ sin = (struct sockaddr_in *)ss;
-+ return (sin->sin_port);
-+ } else {
-+ sin6 = (struct sockaddr_in6 *)ss;
-+ return (sin6->sin6_port);
-+ }
-+}
-+
-+static void *
-+psutil_sockaddr_addr(int family, struct sockaddr_storage *ss)
-+{
-+ struct sockaddr_in6 *sin6;
-+ struct sockaddr_in *sin;
-+
-+ if (family == AF_INET) {
-+ sin = (struct sockaddr_in *)ss;
-+ return (&sin->sin_addr);
-+ } else {
-+ sin6 = (struct sockaddr_in6 *)ss;
-+ return (&sin6->sin6_addr);
-+ }
-+}
-+
-+static socklen_t
-+psutil_sockaddr_addrlen(int family)
-+{
-+ if (family == AF_INET)
-+ return (sizeof(struct in_addr));
-+ else
-+ return (sizeof(struct in6_addr));
-+}
-+
-+static int
-+psutil_sockaddr_matches(int family, int port, void *pcb_addr,
-+ struct sockaddr_storage *ss)
-+{
-+ if (psutil_sockaddr_port(family, ss) != port)
-+ return (0);
-+ return (memcmp(psutil_sockaddr_addr(family, ss), pcb_addr,
-+ psutil_sockaddr_addrlen(family)) == 0);
-+}
-+
-+static struct tcpcb *
-+psutil_search_tcplist(char *buf, struct kinfo_file *kif)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+// a signaler for connections without an actual status
-+static int PSUTIL_CONN_NONE = 128;
-+
-+/*
-+ * Return connections opened by process.
-+ */
-+static PyObject*
-+get_process_connections(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python list of tuple representing per-cpu times
-+ */
-+static PyObject*
-+get_system_per_cpu_times(PyObject* self, PyObject* args)
-+{
-+ int mib[2];
-+ int ncpu;
-+ size_t size;
-+ int i;
-+ PyObject* py_retlist = PyList_New(0);
-+ PyObject* py_cputime = NULL;
-+ long cpu_time[MAXCPUS][CPUSTATES];
-+
-+ if (py_retlist == NULL)
-+ return NULL;
-+
-+ // retrieve the number of cpus
-+ mib[0] = CTL_HW;
-+ mib[1] = HW_NCPU;
-+ size = sizeof(ncpu);
-+ if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+
-+ // per-cpu info
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_CP_TIME;
-+ size = sizeof(cpu_time);
-+ if (sysctl(mib, 2, cpu_time, &size, NULL, 0) == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+
-+ for (i = 0; i < ncpu; i++) {
-+ py_cputime = Py_BuildValue("(ddddd)",
-+ (double)cpu_time[i][CP_USER] / CLOCKS_PER_SEC,
-+ (double)cpu_time[i][CP_NICE] / CLOCKS_PER_SEC,
-+ (double)cpu_time[i][CP_SYS] / CLOCKS_PER_SEC,
-+ (double)cpu_time[i][CP_IDLE] / CLOCKS_PER_SEC,
-+ (double)cpu_time[i][CP_INTR] / CLOCKS_PER_SEC
-+ );
-+ if (!py_cputime)
-+ goto error;
-+ if (PyList_Append(py_retlist, py_cputime))
-+ goto error;
-+ Py_DECREF(py_cputime);
-+ }
-+
-+ return py_retlist;
-+
-+error:
-+ Py_XDECREF(py_cputime);
-+ Py_DECREF(py_retlist);
-+ return NULL;
-+}
-+
-+
-+// remove spaces from string
-+void remove_spaces(char *str) {
-+ char *p1 = str;
-+ char *p2 = str;
-+ do
-+ while (*p2 == ' ')
-+ p2++;
-+ while (*p1++ = *p2++);
-+}
-+
-+/*
-+ * Return a list of tuples for every process memory maps.
-+ * 'procstat' cmdline utility has been used as an example.
-+ */
-+static PyObject*
-+get_process_memory_maps(PyObject* self, PyObject* args)
-+{
-+ /** \todo: implement */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a list of tuples including device, mount point and fs type
-+ * for all partitions mounted on the system.
-+ */
-+static PyObject*
-+get_disk_partitions(PyObject* self, PyObject* args)
-+{
-+ int num;
-+ int i;
-+ long len;
-+ uint64_t flags;
-+ char opts[200];
-+ struct statvfs *fs = NULL;
-+ PyObject* py_retlist = PyList_New(0);
-+ PyObject* py_tuple = NULL;
-+
-+ if (py_retlist == NULL)
-+ return NULL;
-+
-+ // get the number of mount points
-+ Py_BEGIN_ALLOW_THREADS
-+ num = getvfsstat(NULL, 0, MNT_NOWAIT);
-+ Py_END_ALLOW_THREADS
-+ if (num == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+
-+ len = sizeof(*fs) * num;
-+ fs = malloc(len);
-+ if (fs == NULL) {
-+ PyErr_NoMemory();
-+ goto error;
-+ }
-+
-+ Py_BEGIN_ALLOW_THREADS
-+ num = getvfsstat(fs, len, MNT_NOWAIT);
-+ Py_END_ALLOW_THREADS
-+ if (num == -1) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+
-+ for (i = 0; i < num; i++) {
-+ py_tuple = NULL;
-+ opts[0] = 0;
-+ flags = fs[i].f_flag;
-+
-+ // see sys/mount.h
-+ if (flags & MNT_RDONLY)
-+ strlcat(opts, "ro", sizeof(opts));
-+ else
-+ strlcat(opts, "rw", sizeof(opts));
-+ if (flags & ST_NOEXEC)
-+ strlcat(opts, ",noexec", sizeof(opts));
-+ if (flags & ST_NOSUID)
-+ strlcat(opts, ",nosuid", sizeof(opts));
-+ if (flags & ST_NODEV)
-+ strlcat(opts, ",nodev", sizeof(opts));
-+ if (flags & ST_UNION)
-+ strlcat(opts, ",union", sizeof(opts));
-+ if (flags & ST_SYNCHRONOUS)
-+ strlcat(opts, ",sync", sizeof(opts));
-+ if (flags & ST_ASYNC)
-+ strlcat(opts, ",async", sizeof(opts));
-+ if (flags & ST_NOCOREDUMP)
-+ strlcat(opts, ",nocoredump", sizeof(opts));
-+ if (flags & ST_NOATIME)
-+ strlcat(opts, ",noatime", sizeof(opts));
-+ if (flags & ST_SYMPERM)
-+ strlcat(opts, ",symperm", sizeof(opts));
-+ if (flags & ST_NODEVMTIME)
-+ strlcat(opts, ",nodevmtime", sizeof(opts));
-+ if (flags & ST_LOG)
-+ strlcat(opts, ",log", sizeof(opts));
-+ if (flags & ST_LOCAL)
-+ strlcat(opts, ",local", sizeof(opts));
-+ if (flags & ST_QUOTA)
-+ strlcat(opts, ",quota", sizeof(opts));
-+ if (flags & ST_ROOTFS)
-+ strlcat(opts, ",rootfs", sizeof(opts));
-+ if (flags & ST_EXRDONLY)
-+ strlcat(opts, ",exrdonly", sizeof(opts));
-+ if (flags & ST_EXPORTED)
-+ strlcat(opts, ",exported", sizeof(opts));
-+ if (flags & ST_DEFEXPORTED)
-+ strlcat(opts, ",defexported", sizeof(opts));
-+ if (flags & ST_EXPORTANON)
-+ strlcat(opts, ",exportanon", sizeof(opts));
-+ if (flags & ST_EXKERB)
-+ strlcat(opts, ",exkerb", sizeof(opts));
-+ if (flags & ST_EXNORESPORT)
-+ strlcat(opts, ",exnoresport", sizeof(opts));
-+ if (flags & ST_EXPUBLIC)
-+ strlcat(opts, ",expublic", sizeof(opts));
-+
-+ py_tuple = Py_BuildValue("(ssss)", fs[i].f_mntfromname, // device
-+ fs[i].f_mntonname, // mount point
-+ fs[i].f_fstypename, // fs type
-+ opts); // options
-+ if (!py_tuple)
-+ goto error;
-+ if (PyList_Append(py_retlist, py_tuple))
-+ goto error;
-+ Py_DECREF(py_tuple);
-+ }
-+
-+ free(fs);
-+ return py_retlist;
-+
-+error:
-+ Py_XDECREF(py_tuple);
-+ Py_DECREF(py_retlist);
-+ if (fs != NULL)
-+ free(fs);
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python list of named tuples with overall network I/O information
-+ */
-+static PyObject*
-+get_net_io_counters(PyObject* self, PyObject* args)
-+{
-+ char *buf = NULL, *lim, *next;
-+ struct if_msghdr *ifm;
-+ int mib[6];
-+ size_t len;
-+ PyObject* py_retdict = PyDict_New();
-+ PyObject* py_ifc_info = NULL;
-+ if (py_retdict == NULL)
-+ return NULL;
-+
-+ mib[0] = CTL_NET; // networking subsystem
-+ mib[1] = PF_ROUTE; // type of information
-+ mib[2] = 0; // protocol (IPPROTO_xxx)
-+ mib[3] = 0; // address family
-+ mib[4] = NET_RT_IFLIST; // operation
-+ mib[5] = 0;
-+
-+ if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+
-+ buf = malloc(len);
-+ if (buf == NULL) {
-+ PyErr_NoMemory();
-+ goto error;
-+ }
-+
-+ if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
-+ PyErr_SetFromErrno(PyExc_OSError);
-+ goto error;
-+ }
-+
-+ lim = buf + len;
-+
-+ for (next = buf; next < lim; ) {
-+ py_ifc_info = NULL;
-+ ifm = (struct if_msghdr *)next;
-+ next += ifm->ifm_msglen;
-+
-+ if (ifm->ifm_type == RTM_IFINFO) {
-+ struct if_msghdr *if2m = (struct if_msghdr *)ifm;
-+ struct sockaddr_dl *sdl = (struct sockaddr_dl *)(if2m + 1);
-+ char ifc_name[32];
-+
-+ strncpy(ifc_name, sdl->sdl_data, sdl->sdl_nlen);
-+ ifc_name[sdl->sdl_nlen] = 0;
-+ // XXX: ignore usbus interfaces:
-+ // http://lists.freebsd.org/pipermail/freebsd-current/2011-October/028752.html
-+ // 'ifconfig -a' doesn't show them, nor do we.
-+ if (strncmp(ifc_name, "usbus", 5) == 0) {
-+ continue;
-+ }
-+
-+ py_ifc_info = Py_BuildValue("(kkkkkkki)",
-+ if2m->ifm_data.ifi_obytes,
-+ if2m->ifm_data.ifi_ibytes,
-+ if2m->ifm_data.ifi_opackets,
-+ if2m->ifm_data.ifi_ipackets,
-+ if2m->ifm_data.ifi_ierrors,
-+ if2m->ifm_data.ifi_oerrors,
-+ if2m->ifm_data.ifi_iqdrops,
-+ 0); // dropout not supported
-+ if (!py_ifc_info)
-+ goto error;
-+ if (PyDict_SetItemString(py_retdict, ifc_name, py_ifc_info))
-+ goto error;
-+ Py_DECREF(py_ifc_info);
-+ }
-+ else {
-+ continue;
-+ }
-+ }
-+
-+ free(buf);
-+ return py_retdict;
-+
-+error:
-+ Py_XDECREF(py_ifc_info);
-+ Py_DECREF(py_retdict);
-+ if (buf != NULL)
-+ free(buf);
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return a Python dict of tuples for disk I/O information
-+ */
-+static PyObject*
-+get_disk_io_counters(PyObject* self, PyObject* args)
-+{
-+ /** \todo: not implemented */
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return currently connected users as a list of tuples.
-+ */
-+static PyObject*
-+get_system_users(PyObject* self, PyObject* args)
-+{
-+ PyObject *ret_list = PyList_New(0);
-+ PyObject *tuple = NULL;
-+
-+ if (ret_list == NULL)
-+ return NULL;
-+
-+ struct utmpx *utx;
-+
-+ while ((utx = getutxent()) != NULL) {
-+ if (utx->ut_type != USER_PROCESS)
-+ continue;
-+ tuple = Py_BuildValue("(sssf)",
-+ utx->ut_user, // username
-+ utx->ut_line, // tty
-+ utx->ut_host, // hostname
-+ (float)utx->ut_tv.tv_sec // start time
-+ );
-+ if (!tuple) {
-+ endutxent();
-+ goto error;
-+ }
-+ if (PyList_Append(ret_list, tuple)) {
-+ endutxent();
-+ goto error;
-+ }
-+ Py_DECREF(tuple);
-+ }
-+
-+ endutxent();
-+ return ret_list;
-+
-+error:
-+ Py_XDECREF(tuple);
-+ Py_DECREF(ret_list);
-+ return NULL;
-+}
-+
-+
-+/*
-+ * define the psutil C module methods and initialize the module.
-+ */
-+static PyMethodDef
-+PsutilMethods[] =
-+{
-+ // --- per-process functions
-+
-+ {"get_process_name", get_process_name, METH_VARARGS,
-+ "Return process name"},
-+ {"get_process_connections", get_process_connections, METH_VARARGS,
-+ "Return connections opened by process"},
-+ {"get_process_exe", get_process_exe, METH_VARARGS,
-+ "Return process pathname executable"},
-+ {"get_process_cmdline", get_process_cmdline, METH_VARARGS,
-+ "Return process cmdline as a list of cmdline arguments"},
-+ {"get_process_ppid", get_process_ppid, METH_VARARGS,
-+ "Return process ppid as an integer"},
-+ {"get_process_uids", get_process_uids, METH_VARARGS,
-+ "Return process real effective and saved user ids as a Python tuple"},
-+ {"get_process_gids", get_process_gids, METH_VARARGS,
-+ "Return process real effective and saved group ids as a Python tuple"},
-+ {"get_process_cpu_times", get_process_cpu_times, METH_VARARGS,
-+ "Return tuple of user/kern time for the given PID"},
-+ {"get_process_create_time", get_process_create_time, METH_VARARGS,
-+ "Return a float indicating the process create time expressed in "
-+ "seconds since the epoch"},
-+ {"get_process_memory_info", get_process_memory_info, METH_VARARGS,
-+ "Return extended memory info for a process as a Python tuple."},
-+ {"get_process_num_threads", get_process_num_threads, METH_VARARGS,
-+ "Return number of threads used by process"},
-+ {"get_process_num_ctx_switches", get_process_num_ctx_switches, METH_VARARGS,
-+ "Return the number of context switches performed by process"},
-+ {"get_process_threads", get_process_threads, METH_VARARGS,
-+ "Return process threads"},
-+ {"get_process_status", get_process_status, METH_VARARGS,
-+ "Return process status as an integer"},
-+ {"get_process_io_counters", get_process_io_counters, METH_VARARGS,
-+ "Return process IO counters"},
-+ {"get_process_tty_nr", get_process_tty_nr, METH_VARARGS,
-+ "Return process tty (terminal) number"},
-+ {"get_process_open_files", get_process_open_files, METH_VARARGS,
-+ "Return files opened by process as a list of (path, fd) tuples"},
-+ {"get_process_cwd", get_process_cwd, METH_VARARGS,
-+ "Return process current working directory."},
-+ {"get_process_memory_maps", get_process_memory_maps, METH_VARARGS,
-+ "Return a list of tuples for every process's memory map"},
-+ {"get_process_num_fds", get_process_num_fds, METH_VARARGS,
-+ "Return the number of file descriptors opened by this process"},
-+
-+ // --- system-related functions
-+
-+ {"get_pid_list", get_pid_list, METH_VARARGS,
-+ "Returns a list of PIDs currently running on the system"},
-+ {"get_num_cpus", get_num_cpus, METH_VARARGS,
-+ "Return number of CPUs on the system"},
-+ {"get_virtual_mem", get_virtual_mem, METH_VARARGS,
-+ "Return system virtual memory usage statistics"},
-+ {"get_swap_mem", get_swap_mem, METH_VARARGS,
-+ "Return swap mem stats"},
-+ {"get_system_cpu_times", get_system_cpu_times, METH_VARARGS,
-+ "Return system cpu times as a tuple (user, system, nice, idle, irc)"},
-+ {"get_system_per_cpu_times", get_system_per_cpu_times, METH_VARARGS,
-+ "Return system per-cpu times as a list of tuples"},
-+ {"get_system_boot_time", get_system_boot_time, METH_VARARGS,
-+ "Return the system boot time expressed in seconds since the epoch."},
-+ {"get_disk_partitions", get_disk_partitions, METH_VARARGS,
-+ "Return a list of tuples including device, mount point and "
-+ "fs type for all partitions mounted on the system."},
-+ {"get_net_io_counters", get_net_io_counters, METH_VARARGS,
-+ "Return dict of tuples of networks I/O information."},
-+ {"get_disk_io_counters", get_disk_io_counters, METH_VARARGS,
-+ "Return a Python dict of tuples for disk I/O information"},
-+ {"get_system_users", get_system_users, METH_VARARGS,
-+ "Return currently connected users as a list of tuples"},
-+
-+ {NULL, NULL, 0, NULL}
-+};
-+
-+struct module_state {
-+ PyObject *error;
-+};
-+
-+#if PY_MAJOR_VERSION >= 3
-+#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
-+#else
-+#define GETSTATE(m) (&_state)
-+#endif
-+
-+#if PY_MAJOR_VERSION >= 3
-+
-+static int
-+psutil_netbsd_traverse(PyObject *m, visitproc visit, void *arg) {
-+ Py_VISIT(GETSTATE(m)->error);
-+ return 0;
-+}
-+
-+static int
-+psutil_netbsd_clear(PyObject *m) {
-+ Py_CLEAR(GETSTATE(m)->error);
-+ return 0;
-+}
-+
-+static struct PyModuleDef
-+moduledef = {
-+ PyModuleDef_HEAD_INIT,
-+ "psutil_netbsd",
-+ NULL,
-+ sizeof(struct module_state),
-+ PsutilMethods,
-+ NULL,
-+ psutil_netbsd_traverse,
-+ psutil_netbsd_clear,
-+ NULL
-+};
-+
-+#define INITERROR return NULL
-+
-+PyObject *
-+PyInit__psutil_netbsd(void)
-+
-+#else
-+#define INITERROR return
-+
-+void init_psutil_netbsd(void)
-+#endif
-+{
-+#if PY_MAJOR_VERSION >= 3
-+ PyObject *module = PyModule_Create(&moduledef);
-+#else
-+ PyObject *module = Py_InitModule("_psutil_netbsd", PsutilMethods);
-+#endif
-+ // process status constants
-+ PyModule_AddIntConstant(module, "SIDL", SIDL);
-+ PyModule_AddIntConstant(module, "SACTIVE", SACTIVE);
-+ PyModule_AddIntConstant(module, "SDYING", SDYING);
-+ PyModule_AddIntConstant(module, "SSTOP", SSTOP);
-+ PyModule_AddIntConstant(module, "SZOMB", SZOMB);
-+ PyModule_AddIntConstant(module, "SDEAD", SDEAD);
-+ // connection status constants
-+ PyModule_AddIntConstant(module, "TCPS_CLOSED", TCPS_CLOSED);
-+ PyModule_AddIntConstant(module, "TCPS_CLOSING", TCPS_CLOSING);
-+ PyModule_AddIntConstant(module, "TCPS_CLOSE_WAIT", TCPS_CLOSE_WAIT);
-+ PyModule_AddIntConstant(module, "TCPS_LISTEN", TCPS_LISTEN);
-+ PyModule_AddIntConstant(module, "TCPS_ESTABLISHED", TCPS_ESTABLISHED);
-+ PyModule_AddIntConstant(module, "TCPS_SYN_SENT", TCPS_SYN_SENT);
-+ PyModule_AddIntConstant(module, "TCPS_SYN_RECEIVED", TCPS_SYN_RECEIVED);
-+ PyModule_AddIntConstant(module, "TCPS_FIN_WAIT_1", TCPS_FIN_WAIT_1);
-+ PyModule_AddIntConstant(module, "TCPS_FIN_WAIT_2", TCPS_FIN_WAIT_2);
-+ PyModule_AddIntConstant(module, "TCPS_LAST_ACK", TCPS_LAST_ACK);
-+ PyModule_AddIntConstant(module, "TCPS_TIME_WAIT", TCPS_TIME_WAIT);
-+
-+ if (module == NULL) {
-+ INITERROR;
-+ }
-+#if PY_MAJOR_VERSION >= 3
-+ return module;
-+#endif
-+}
diff --git a/sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.h b/sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.h
deleted file mode 100644
index 2e7167c1b5b..00000000000
--- a/sysutils/py-psutil/patches/patch-psutil___psutil__netbsd.h
+++ /dev/null
@@ -1,57 +0,0 @@
-$NetBSD: patch-psutil___psutil__netbsd.h,v 1.1 2013/10/12 13:32:36 wiz Exp $
-
-Port to NetBSD.
-
---- psutil/_psutil_netbsd.h.orig 2013-10-12 13:19:29.000000000 +0000
-+++ psutil/_psutil_netbsd.h
-@@ -0,0 +1,50 @@
-+/*
-+ * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
-+ * Use of this source code is governed by a BSD-style license that can be
-+ * found in the LICENSE file.
-+ *
-+ * NetBSD platform-specific module methods for _psutil_netbsd
-+ */
-+
-+#include <Python.h>
-+
-+// --- per-process functions
-+
-+static PyObject* get_process_cpu_times(PyObject* self, PyObject* args);
-+static PyObject* get_process_name(PyObject* self, PyObject* args);
-+static PyObject* get_process_exe(PyObject* self, PyObject* args);
-+static PyObject* get_process_cmdline(PyObject* self, PyObject* args);
-+static PyObject* get_process_ppid(PyObject* self, PyObject* args);
-+static PyObject* get_process_uids(PyObject* self, PyObject* args);
-+static PyObject* get_process_gids(PyObject* self, PyObject* args);
-+static PyObject* get_process_connections(PyObject* self, PyObject* args);
-+static PyObject* get_process_create_time(PyObject* self, PyObject* args);
-+static PyObject* get_process_memory_info(PyObject* self, PyObject* args);
-+static PyObject* get_process_num_threads(PyObject* self, PyObject* args);
-+static PyObject* get_process_num_fds(PyObject* self, PyObject* args);
-+static PyObject* get_process_threads(PyObject* self, PyObject* args);
-+static PyObject* get_process_status(PyObject* self, PyObject* args);
-+static PyObject* get_process_io_counters(PyObject* self, PyObject* args);
-+static PyObject* get_process_tty_nr(PyObject* self, PyObject* args);
-+static PyObject* get_process_memory_maps(PyObject* self, PyObject* args);
-+static PyObject* get_process_num_ctx_switches(PyObject* self, PyObject* args);
-+#if NOTYET
-+static PyObject* get_process_open_files(PyObject* self, PyObject* args);
-+static PyObject* get_process_cwd(PyObject* self, PyObject* args);
-+#endif
-+
-+// --- system-related functions
-+
-+static PyObject* get_pid_list(PyObject* self, PyObject* args);
-+static PyObject* get_num_cpus(PyObject* self, PyObject* args);
-+static PyObject* get_virtual_mem(PyObject* self, PyObject* args);
-+static PyObject* get_swap_mem(PyObject* self, PyObject* args);
-+static PyObject* get_system_cpu_times(PyObject* self, PyObject* args);
-+#if NOTYET
-+static PyObject* get_system_per_cpu_times(PyObject* self, PyObject* args);
-+#endif
-+static PyObject* get_system_boot_time(PyObject* self, PyObject* args);
-+static PyObject* get_disk_partitions(PyObject* self, PyObject* args);
-+static PyObject* get_net_io_counters(PyObject* self, PyObject* args);
-+static PyObject* get_disk_io_counters(PyObject* self, PyObject* args);
-+static PyObject* get_system_users(PyObject* self, PyObject* args);
diff --git a/sysutils/py-psutil/patches/patch-psutil___psutil__posix.c b/sysutils/py-psutil/patches/patch-psutil___psutil__posix.c
new file mode 100644
index 00000000000..ea72a2c2ce1
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil___psutil__posix.c
@@ -0,0 +1,49 @@
+$NetBSD: patch-psutil___psutil__posix.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/_psutil_posix.c.orig 2015-11-25 01:20:34.000000000 +0000
++++ psutil/_psutil_posix.c
+@@ -26,7 +26,7 @@
+ #include <linux/if_packet.h>
+ #endif // end linux
+
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+ #include <netdb.h>
+ #include <netinet/in.h>
+ #include <net/if_dl.h>
+@@ -120,7 +120,7 @@ psutil_convert_ipaddr(struct sockaddr *a
+ data = (const char *)lladdr->sll_addr;
+ }
+ #endif
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+ else if (addr->sa_family == AF_LINK) {
+ // Note: prior to Python 3.4 socket module does not expose
+ // AF_LINK so we'll do.
+@@ -250,7 +250,7 @@ error:
+ * net_if_stats() implementation. This is here because it is common
+ * to both OSX and FreeBSD and I didn't know where else to put it.
+ */
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+
+ #include <sys/sockio.h>
+ #include <net/if_media.h>
+@@ -478,7 +478,7 @@ PsutilMethods[] = {
+ "Set process priority"},
+ {"net_if_addrs", psutil_net_if_addrs, METH_VARARGS,
+ "Retrieve NICs information"},
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__)
+ {"net_if_stats", psutil_net_if_stats, METH_VARARGS,
+ "Return NIC stats."},
+ #endif
+@@ -537,7 +537,7 @@ void init_psutil_posix(void)
+ PyObject *module = Py_InitModule("_psutil_posix", PsutilMethods);
+ #endif
+
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__sun)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__sun) || defined(__NetBSD__)
+ PyModule_AddIntConstant(module, "AF_LINK", AF_LINK);
+ #endif
+
diff --git a/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.c b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.c
new file mode 100644
index 00000000000..a924a2c1217
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.c
@@ -0,0 +1,670 @@
+$NetBSD: patch-psutil_arch_bsd_netbsd.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/arch/bsd/netbsd.c.orig 2015-11-30 22:46:00.000000000 +0000
++++ psutil/arch/bsd/netbsd.c
+@@ -0,0 +1,665 @@
++/*
++ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
++ * All rights reserved.
++ * Use of this source code is governed by a BSD-style license that can be
++ * found in the LICENSE file.
++ *
++ * Platform-specific module methods for NetBSD.
++ */
++
++#if defined(__NetBSD__)
++#define _KMEMUSER
++#endif
++
++#include <Python.h>
++#include <assert.h>
++#include <errno.h>
++#include <stdlib.h>
++#include <stdio.h>
++#include <string.h>
++#include <fcntl.h>
++#include <sys/types.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <sys/user.h>
++#include <sys/proc.h>
++#include <sys/swap.h> // for swap_mem
++#include <signal.h>
++#include <kvm.h>
++// connection stuff
++#include <netdb.h> // for NI_MAXHOST
++#include <sys/socket.h>
++#include <sys/sched.h> // for CPUSTATES & CP_*
++#define _KERNEL // for DTYPE_*
++#include <sys/file.h>
++#undef _KERNEL
++#include <sys/disk.h> // struct diskstats
++#include <netinet/in.h>
++#include <arpa/inet.h>
++
++
++#include "netbsd.h"
++#include "netbsd_socks.h"
++
++#define PSUTIL_KPT2DOUBLE(t) (t ## _sec + t ## _usec / 1000000.0)
++#define PSUTIL_TV2DOUBLE(t) ((t).tv_sec + (t).tv_usec / 1000000.0)
++
++
++// ============================================================================
++// Utility functions
++// ============================================================================
++
++int
++psutil_kinfo_proc(pid_t pid, kinfo_proc *proc) {
++ // Fills a kinfo_proc struct based on process pid.
++ int ret;
++ int mib[6];
++ size_t size = sizeof(kinfo_proc);
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC2;
++ mib[2] = KERN_PROC_PID;
++ mib[3] = pid;
++ mib[4] = size;
++ mib[5] = 1;
++
++ ret = sysctl((int*)mib, 6, proc, &size, NULL, 0);
++ if (ret == -1) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return -1;
++ }
++ // sysctl stores 0 in the size if we can't find the process information.
++ if (size == 0) {
++ NoSuchProcess();
++ return -1;
++ }
++ return 0;
++}
++
++
++struct kinfo_file *
++kinfo_getfile(pid_t pid, int* cnt) {
++ // Mimic's FreeBSD kinfo_file call, taking a pid and a ptr to an
++ // int as arg and returns an array with cnt struct kinfo_file.
++ int mib[6];
++ size_t len;
++ struct kinfo_file* kf;
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_FILE2;
++ mib[2] = KERN_FILE_BYPID;
++ mib[3] = (int) pid;
++ mib[4] = sizeof(struct kinfo_file);
++ mib[5] = 0;
++
++ /* get the size of what would be returned */
++ if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++ if ((kf = malloc(len)) == NULL) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++ mib[5] = (int)(len / sizeof(struct kinfo_file));
++ if (sysctl(mib, 6, kf, &len, NULL, 0) < 0) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++
++ *cnt = (int)(len / sizeof(struct kinfo_file));
++ return kf;
++}
++
++
++int
++psutil_pid_exists(pid_t pid) {
++ // Return 1 if PID exists in the current process list, else 0, -1
++ // on error.
++ // TODO: this should live in _psutil_posix.c but for some reason if I
++ // move it there I get a "include undefined symbol" error.
++ int ret;
++ if (pid < 0)
++ return 0;
++ ret = kill(pid , 0);
++ if (ret == 0)
++ return 1;
++ else {
++ if (ret == ESRCH)
++ return 0;
++ else if (ret == EPERM)
++ return 1;
++ else {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return -1;
++ }
++ }
++}
++
++PyObject *
++psutil_proc_exe(PyObject *self, PyObject *args) {
++#if __NetBSD_Version__ >= 799000000
++ pid_t pid;
++ char pathname[MAXPATHLEN];
++ int error;
++ int mib[4];
++ int ret;
++ size_t size;
++
++ if (! PyArg_ParseTuple(args, "l", &pid))
++ return NULL;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC_ARGS;
++ mib[2] = pid;
++ mib[3] = KERN_PROC_PATHNAME;
++
++ size = sizeof(pathname);
++ error = sysctl(mib, 4, NULL, &size, NULL, 0);
++ if (error == -1) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++
++ error = sysctl(mib, 4, pathname, &size, NULL, 0);
++ if (error == -1) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++ if (size == 0 || strlen(pathname) == 0) {
++ ret = psutil_pid_exists(pid);
++ if (ret == -1)
++ return NULL;
++ else if (ret == 0)
++ return NoSuchProcess();
++ else
++ strcpy(pathname, "");
++ }
++ return Py_BuildValue("s", pathname);
++#else
++ return NULL;
++#endif
++}
++
++PyObject *
++psutil_proc_num_threads(PyObject *self, PyObject *args) {
++ // Return number of threads used by process as a Python integer.
++ long pid;
++ kinfo_proc kp;
++ if (! PyArg_ParseTuple(args, "l", &pid))
++ return NULL;
++ if (psutil_kinfo_proc(pid, &kp) == -1)
++ return NULL;
++ return Py_BuildValue("l", (long)kp.p_nlwps);
++}
++
++PyObject *
++psutil_proc_threads(PyObject *self, PyObject *args) {
++ pid_t pid;
++ int mib[5];
++ int i, nlwps;
++ ssize_t st;
++ size_t size;
++ struct kinfo_lwp *kl;
++ PyObject *py_retlist = PyList_New(0);
++ PyObject *py_tuple = NULL;
++
++ if (py_retlist == NULL)
++ return NULL;
++ if (! PyArg_ParseTuple(args, "l", &pid))
++ goto error;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_LWP;
++ mib[2] = pid;
++ mib[3] = sizeof(struct kinfo_lwp);
++ mib[4] = 0;
++
++ st = sysctl(mib, 5, NULL, &size, NULL, 0);
++ if (st == -1) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ goto error;
++ }
++ if (size == 0) {
++ NoSuchProcess();
++ goto error;
++ }
++
++ mib[4] = size / sizeof(size_t);
++ kl = malloc(size);
++ if (kl == NULL) {
++ PyErr_NoMemory();
++ goto error;
++ }
++
++ st = sysctl(mib, 5, kl, &size, NULL, 0);
++ if (st == -1) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ goto error;
++ }
++ if (size == 0) {
++ NoSuchProcess();
++ goto error;
++ }
++
++ nlwps = (int)(size / sizeof(struct kinfo_lwp));
++ for (i = 0; i < nlwps; i++) {
++ py_tuple = Py_BuildValue("idd",
++ (&kl[i])->l_lid,
++ PSUTIL_KPT2DOUBLE((&kl[i])->l_rtime),
++ PSUTIL_KPT2DOUBLE((&kl[i])->l_rtime));
++ if (py_tuple == NULL)
++ goto error;
++ if (PyList_Append(py_retlist, py_tuple))
++ goto error;
++ Py_DECREF(py_tuple);
++ }
++ free(kl);
++ return py_retlist;
++
++error:
++ Py_XDECREF(py_tuple);
++ Py_DECREF(py_retlist);
++ if (kl != NULL)
++ free(kl);
++ return NULL;
++}
++
++int
++psutil_raise_ad_or_nsp(long pid) {
++ // Set exception to AccessDenied if pid exists else NoSuchProcess.
++ if (psutil_pid_exists(pid) == 0)
++ NoSuchProcess();
++ else
++ AccessDenied();
++}
++
++
++// ============================================================================
++// APIS
++// ============================================================================
++
++int
++psutil_get_proc_list(kinfo_proc **procList, size_t *procCount) {
++ // Returns a list of all BSD processes on the system. This routine
++ // allocates the list and puts it in *procList and a count of the
++ // number of entries in *procCount. You are responsible for freeing
++ // this list (use "free" from System framework).
++ // On success, the function returns 0.
++ // On error, the function returns a BSD errno value.
++ kinfo_proc *result;
++ int done;
++ static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC, 0 };
++ // Declaring name as const requires us to cast it when passing it to
++ // sysctl because the prototype doesn't include the const modifier.
++ size_t length;
++ char errbuf[_POSIX2_LINE_MAX];
++ kinfo_proc *x;
++ int cnt;
++ kvm_t *kd;
++
++ assert( procList != NULL);
++ assert(*procList == NULL);
++ assert(procCount != NULL);
++
++ kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
++
++ if (kd == NULL) {
++ return errno;
++ }
++
++ result = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(kinfo_proc), &cnt);
++ if (result == NULL) {
++ err(1, NULL);
++ return errno;
++ }
++
++ *procCount = (size_t)cnt;
++
++ size_t mlen = cnt * sizeof(kinfo_proc);
++
++ if ((*procList = malloc(mlen)) == NULL) {
++ err(1, NULL);
++ return errno;
++ }
++
++ memcpy(*procList, result, mlen);
++ assert(*procList != NULL);
++ kvm_close(kd);
++
++ return 0;
++}
++
++
++char *
++psutil_get_cmd_args(pid_t pid, size_t *argsize) {
++ int mib[4];
++ ssize_t st;
++ int argmax;
++ size_t size;
++ char *procargs = NULL;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_ARGMAX;
++
++ size = sizeof(argmax);
++ st = sysctl(mib, 2, &argmax, &size, NULL, 0);
++ if (st == -1)
++ return NULL;
++
++ procargs = (char *)malloc(argmax);
++ if (procargs == NULL)
++ return NULL;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_PROC_ARGS;
++ mib[2] = pid;
++ mib[3] = KERN_PROC_ARGV;
++
++ st = sysctl(mib, 4, procargs, &argmax, NULL, 0);
++ if (st == -1)
++ return NULL;
++
++ *argsize = argmax;
++ return procargs;
++}
++
++// returns the command line as a python list object
++PyObject *
++psutil_get_cmdline(pid_t pid) {
++ char *argstr = NULL;
++ int pos = 0;
++ size_t argsize = 0;
++ PyObject *py_retlist = Py_BuildValue("[]");
++ PyObject *py_arg = NULL;
++
++ if (pid < 0)
++ return py_retlist;
++ argstr = psutil_get_cmd_args(pid, &argsize);
++ if (argstr == NULL)
++ goto error;
++
++ // args are returned as a flattened string with \0 separators between
++ // arguments add each string to the list then step forward to the next
++ // separator
++ if (argsize > 0) {
++ while (pos < argsize) {
++ py_arg = Py_BuildValue("s", &argstr[pos]);
++ if (!py_arg)
++ goto error;
++ if (PyList_Append(py_retlist, py_arg))
++ goto error;
++ Py_DECREF(py_arg);
++ pos = pos + strlen(&argstr[pos]) + 1;
++ }
++ }
++
++ free(argstr);
++ return py_retlist;
++
++error:
++ Py_XDECREF(py_arg);
++ Py_DECREF(py_retlist);
++ if (argstr != NULL)
++ free(argstr);
++ return NULL;
++}
++
++
++PyObject *
++psutil_virtual_mem(PyObject *self, PyObject *args) {
++ unsigned int total, active, inactive, wired, cached, free;
++ size_t size = sizeof(total);
++ struct uvmexp_sysctl uvmexp;
++ int mib[] = {CTL_VM, VM_UVMEXP2};
++ long pagesize = getpagesize();
++ size = sizeof(uvmexp);
++
++ if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
++ warn("failed to get vm.uvmexp");
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++ return Py_BuildValue("KKKKKKKK",
++ (unsigned long long) uvmexp.npages * pagesize,
++ (unsigned long long) uvmexp.free * pagesize,
++ (unsigned long long) uvmexp.active * pagesize,
++ (unsigned long long) uvmexp.inactive * pagesize,
++ (unsigned long long) uvmexp.wired * pagesize,
++ (unsigned long long) 0,
++ (unsigned long long) 0,
++ (unsigned long long) 0
++ );
++}
++
++
++PyObject *
++psutil_swap_mem(PyObject *self, PyObject *args) {
++ uint64_t swap_total, swap_free;
++ struct swapent *swdev;
++ int nswap, i;
++
++ if ((nswap = swapctl(SWAP_NSWAP, 0, 0)) == 0) {
++ warn("failed to get swap device count");
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++
++ if ((swdev = calloc(nswap, sizeof(*swdev))) == NULL) {
++ warn("failed to allocate memory for swdev structures");
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++
++ if (swapctl(SWAP_STATS, swdev, nswap) == -1) {
++ free(swdev);
++ warn("failed to get swap stats");
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++
++ /* Total things up */
++ swap_total = swap_free = 0;
++ for (i = 0; i < nswap; i++) {
++ if (swdev[i].se_flags & SWF_ENABLE) {
++ swap_free += (swdev[i].se_nblks - swdev[i].se_inuse);
++ swap_total += swdev[i].se_nblks;
++ }
++ }
++ return Py_BuildValue("(LLLII)",
++ swap_total * DEV_BSIZE,
++ (swap_total - swap_free) * DEV_BSIZE,
++ swap_free * DEV_BSIZE,
++ 0 /* XXX swap in */,
++ 0 /* XXX swap out */);
++}
++
++
++PyObject *
++psutil_proc_num_fds(PyObject *self, PyObject *args) {
++ long pid;
++ int cnt;
++
++ struct kinfo_file *freep;
++ kinfo_proc kipp;
++
++ if (! PyArg_ParseTuple(args, "l", &pid))
++ return NULL;
++ if (psutil_kinfo_proc(pid, &kipp) == -1)
++ return NULL;
++
++ freep = kinfo_getfile(pid, &cnt);
++ if (freep == NULL) {
++ psutil_raise_ad_or_nsp(pid);
++ return NULL;
++ }
++ free(freep);
++
++ return Py_BuildValue("i", cnt);
++}
++
++
++PyObject *
++psutil_proc_cwd(PyObject *self, PyObject *args) {
++ /* Not implemented */
++ return NULL;
++}
++
++
++// see sys/kern/kern_sysctl.c lines 1100 and
++// usr.bin/fstat/fstat.c print_inet_details()
++static char *
++psutil_convert_ipv4(int family, uint32_t addr[4]) {
++ struct in_addr a;
++ memcpy(&a, addr, sizeof(a));
++ return inet_ntoa(a);
++}
++
++
++static char *
++psutil_inet6_addrstr(struct in6_addr *p)
++{
++ struct sockaddr_in6 sin6;
++ static char hbuf[NI_MAXHOST];
++ const int niflags = NI_NUMERICHOST;
++
++ memset(&sin6, 0, sizeof(sin6));
++ sin6.sin6_family = AF_INET6;
++ sin6.sin6_len = sizeof(struct sockaddr_in6);
++ sin6.sin6_addr = *p;
++ if (IN6_IS_ADDR_LINKLOCAL(p) &&
++ *(u_int16_t *)&sin6.sin6_addr.s6_addr[2] != 0) {
++ sin6.sin6_scope_id =
++ ntohs(*(u_int16_t *)&sin6.sin6_addr.s6_addr[2]);
++ sin6.sin6_addr.s6_addr[2] = sin6.sin6_addr.s6_addr[3] = 0;
++ }
++
++ if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len,
++ hbuf, sizeof(hbuf), NULL, 0, niflags))
++ return "invalid";
++
++ return hbuf;
++}
++
++PyObject *
++psutil_per_cpu_times(PyObject *self, PyObject *args) {
++ static int maxcpus;
++ int mib[3];
++ int ncpu;
++ size_t len;
++ size_t size;
++ int i;
++ PyObject *py_retlist = PyList_New(0);
++ PyObject *py_cputime = NULL;
++
++ if (py_retlist == NULL)
++ return NULL;
++
++
++ // retrieve the number of cpus
++ mib[0] = CTL_HW;
++ mib[1] = HW_NCPU;
++ len = sizeof(ncpu);
++ if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1) {
++ PyErr_SetFromErrno(PyExc_OSError);
++ goto error;
++ }
++ uint64_t cpu_time[CPUSTATES];
++
++ for (i = 0; i < ncpu; i++) {
++ // per-cpu info
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_CP_TIME;
++ mib[2] = i;
++ size = sizeof(cpu_time);
++ if (sysctl(mib, 3, &cpu_time, &size, NULL, 0) == -1) {
++ warn("failed to get kern.cptime2");
++ PyErr_SetFromErrno(PyExc_OSError);
++ return NULL;
++ }
++
++ py_cputime = Py_BuildValue(
++ "(ddddd)",
++ (double)cpu_time[CP_USER] / CLOCKS_PER_SEC,
++ (double)cpu_time[CP_NICE] / CLOCKS_PER_SEC,
++ (double)cpu_time[CP_SYS] / CLOCKS_PER_SEC,
++ (double)cpu_time[CP_IDLE] / CLOCKS_PER_SEC,
++ (double)cpu_time[CP_INTR] / CLOCKS_PER_SEC);
++ if (!py_cputime)
++ goto error;
++ if (PyList_Append(py_retlist, py_cputime))
++ goto error;
++ Py_DECREF(py_cputime);
++ }
++
++ return py_retlist;
++
++error:
++ Py_XDECREF(py_cputime);
++ Py_DECREF(py_retlist);
++ return NULL;
++}
++
++
++PyObject *
++psutil_disk_io_counters(PyObject *self, PyObject *args) {
++ int i, dk_ndrive, mib[3];
++ size_t len;
++ struct io_sysctl *stats;
++
++ PyObject *py_retdict = PyDict_New();
++ PyObject *py_disk_info = NULL;
++ if (py_retdict == NULL)
++ return NULL;
++
++ mib[0] = CTL_HW;
++ mib[1] = HW_IOSTATS;
++ mib[2] = sizeof(struct io_sysctl);
++ len = 0;
++ if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0) {
++ warn("can't get HW_IOSTATS");
++ PyErr_SetFromErrno(PyExc_OSError);
++ goto error;
++ }
++ dk_ndrive = (int)(len / sizeof(struct io_sysctl));
++
++ stats = malloc(len);
++ if (stats == NULL) {
++ warn("can't malloc");
++ PyErr_NoMemory();
++ goto error;
++ }
++ if (sysctl(mib, 2, stats, &len, NULL, 0) < 0 ) {
++ warn("could not read HW_IOSTATS");
++ PyErr_SetFromErrno(PyExc_OSError);
++ goto error;
++ }
++
++ for (i = 0; i < dk_ndrive; i++) {
++ py_disk_info = Py_BuildValue(
++ "(KKKKLL)",
++ stats[i].rxfer,
++ stats[i].wxfer,
++ stats[i].rbytes,
++ stats[i].wbytes,
++ // assume half read - half writes.
++ // TODO: why?
++ (long long) PSUTIL_KPT2DOUBLE(stats[i].time) / 2,
++ (long long) PSUTIL_KPT2DOUBLE(stats[i].time) / 2);
++ if (!py_disk_info)
++ goto error;
++ if (PyDict_SetItemString(py_retdict, stats[i].name, py_disk_info))
++ goto error;
++ Py_DECREF(py_disk_info);
++ }
++
++ free(stats);
++ return py_retdict;
++
++error:
++ Py_XDECREF(py_disk_info);
++ Py_DECREF(py_retdict);
++ if (stats != NULL)
++ free(stats);
++ return NULL;
++}
++
diff --git a/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.h b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.h
new file mode 100644
index 00000000000..b772e788d19
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd.h
@@ -0,0 +1,35 @@
+$NetBSD: patch-psutil_arch_bsd_netbsd.h,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/arch/bsd/netbsd.h.orig 2015-11-30 15:33:35.000000000 +0000
++++ psutil/arch/bsd/netbsd.h
+@@ -0,0 +1,30 @@
++/*
++ * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.
++ * All rights reserved.
++ * Use of this source code is governed by a BSD-style license that can be
++ * found in the LICENSE file.
++ */
++
++#include <Python.h>
++
++typedef struct kinfo_proc2 kinfo_proc;
++
++int psutil_kinfo_proc(pid_t pid, kinfo_proc *proc);
++struct kinfo_file * kinfo_getfile(pid_t pid, int* cnt);
++int psutil_get_proc_list(kinfo_proc **procList, size_t *procCount);
++char *psutil_get_cmd_args(pid_t pid, size_t *argsize);
++PyObject * psutil_get_cmdline(pid_t pid);
++int psutil_pid_exists(pid_t pid);
++int psutil_raise_ad_or_nsp(long pid);
++
++//
++PyObject *psutil_proc_threads(PyObject *self, PyObject *args);
++PyObject *psutil_virtual_mem(PyObject *self, PyObject *args);
++PyObject *psutil_swap_mem(PyObject *self, PyObject *args);
++PyObject *psutil_proc_num_fds(PyObject *self, PyObject *args);
++PyObject *psutil_proc_cwd(PyObject *self, PyObject *args);
++PyObject *psutil_proc_connections(PyObject *self, PyObject *args);
++PyObject *psutil_per_cpu_times(PyObject *self, PyObject *args);
++PyObject* psutil_disk_io_counters(PyObject* self, PyObject* args);
++PyObject* psutil_proc_exe(PyObject* self, PyObject* args);
++PyObject* psutil_proc_num_threads(PyObject* self, PyObject* args);
diff --git a/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.c b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.c
new file mode 100644
index 00000000000..ab4007369eb
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.c
@@ -0,0 +1,540 @@
+$NetBSD: patch-psutil_arch_bsd_netbsd__socks.c,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/arch/bsd/netbsd_socks.c.orig 2015-11-30 15:55:46.000000000 +0000
++++ psutil/arch/bsd/netbsd_socks.c
+@@ -0,0 +1,535 @@
++/*
++ * Copyright (c) 2009, Giampaolo Rodola'.
++ * Copyright (c) 2015, Ryo ONODERA.
++ * All rights reserved.
++ * Use of this source code is governed by a BSD-style license that can be
++ * found in the LICENSE file.
++ */
++#include <Python.h>
++#include <errno.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <sys/sysctl.h>
++#include <sys/socket.h>
++#include <sys/types.h>
++#include <netinet/in.h>
++#include <string.h>
++#include <sys/cdefs.h>
++#include <arpa/inet.h>
++#include <sys/queue.h>
++#include <sys/un.h>
++#include <sys/file.h>
++
++// a signaler for connections without an actual status
++int PSUTIL_CONN_NONE = 128;
++
++/* Address family filter */
++enum af_filter {
++ INET,
++ INET4,
++ INET6,
++ TCP,
++ TCP4,
++ TCP6,
++ UDP,
++ UDP4,
++ UDP6,
++ UNIX,
++ ALL,
++};
++
++/* kinfo_file results */
++struct kif {
++ SLIST_ENTRY(kif) kifs;
++ struct kinfo_file *kif;
++};
++
++/* kinfo_file results list */
++SLIST_HEAD(kifhead, kif) kihead = SLIST_HEAD_INITIALIZER(kihead);
++
++
++/* kinfo_pcb results */
++struct kpcb {
++ SLIST_ENTRY(kpcb) kpcbs;
++ struct kinfo_pcb *kpcb;
++};
++
++/* kinfo_pcb results list */
++SLIST_HEAD(kpcbhead, kpcb) kpcbhead = SLIST_HEAD_INITIALIZER(kpcbhead);
++
++static void kiflist_init(void);
++static void kiflist_clear(void);
++static void kpcblist_init(void);
++static void kpcblist_clear(void);
++static int get_files(void);
++static int get_sockets(const char *name);
++static void get_info(int aff);
++
++/* Initialize kinfo_file results list */
++static void
++kiflist_init(void)
++{
++ SLIST_INIT(&kihead);
++ return;
++}
++
++/* Clear kinfo_file results list */
++static void
++kiflist_clear(void)
++{
++ while (!SLIST_EMPTY(&kihead)) {
++ SLIST_REMOVE_HEAD(&kihead, kifs);
++ }
++
++ return;
++}
++
++/* Initialize kinof_pcb result list */
++static void
++kpcblist_init(void)
++{
++ SLIST_INIT(&kpcbhead);
++ return;
++}
++
++/* Clear kinof_pcb result list */
++static void
++kpcblist_clear(void)
++{
++ while (!SLIST_EMPTY(&kpcbhead)) {
++ SLIST_REMOVE_HEAD(&kpcbhead, kpcbs);
++ }
++
++ return;
++}
++
++
++/*
++ * Get all open files including socket
++ */
++static int
++get_files(void)
++{
++ size_t len;
++ int mib[6];
++ char *buf;
++ off_t offset;
++ int j;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_FILE2;
++ mib[2] = KERN_FILE_BYFILE;
++ mib[3] = 0;
++ mib[4] = sizeof(struct kinfo_file);
++ mib[5] = 0;
++
++ if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
++ return -1;
++ offset = len % sizeof(off_t);
++ mib[5] = len / sizeof(struct kinfo_file);
++ if ((buf = malloc(len + offset)) == NULL)
++ return -1;
++ if (sysctl(mib, 6, buf + offset, &len, NULL, 0) == -1) {
++ free(buf);
++ return -1;
++ }
++
++ len /= sizeof(struct kinfo_file);
++ struct kinfo_file *ki = (struct kinfo_file *)(buf + offset);
++
++ for (j = 0; j < len; j++) {
++ struct kif *kif = malloc(sizeof(struct kif));
++ kif->kif = &ki[j];
++ SLIST_INSERT_HEAD(&kihead, kif, kifs);
++ }
++
++#if 0
++ /* debug */
++ struct kif *k;
++ SLIST_FOREACH(k, &kihead, kifs) {
++ printf("%d\n", k->kif->ki_pid);
++ }
++#endif
++
++ return 0;
++}
++
++/*
++ * Get open sockets
++ */
++static int
++get_sockets(const char *name)
++{
++ size_t namelen;
++ int mib[8];
++ int ret, j;
++ struct kinfo_pcb *pcb;
++ size_t len;
++
++ memset(mib, 0, sizeof(mib));
++
++ if (sysctlnametomib(name, mib, &namelen) == -1)
++ return -1;
++
++ if (sysctl(mib, __arraycount(mib), NULL, &len, NULL, 0) == -1)
++ return -1;
++
++ if ((pcb = malloc(len)) == NULL) {
++ free(pcb);
++ return -1;
++ }
++ memset(pcb, 0, len);
++
++ mib[6] = sizeof(*pcb);
++ mib[7] = len / sizeof(*pcb);
++
++ if (sysctl(mib, __arraycount(mib), pcb, &len, NULL, 0) == -1) {
++ return -1;
++ }
++
++ len /= sizeof(struct kinfo_pcb);
++ struct kinfo_pcb *kp = (struct kinfo_pcb *)pcb;
++
++ for (j = 0; j < len; j++) {
++ struct kpcb *kpcb = malloc(sizeof(struct kpcb));
++ kpcb->kpcb = &kp[j];
++ SLIST_INSERT_HEAD(&kpcbhead, kpcb, kpcbs);
++ }
++
++#if 0
++ /* debug */
++ struct kif *k;
++ struct kpcb *k;
++ SLIST_FOREACH(k, &kpcbhead, kpcbs) {
++ printf("ki_type: %d\n", k->kpcb->ki_type);
++ printf("ki_family: %d\n", k->kpcb->ki_family);
++ }
++#endif
++
++ return 0;
++}
++
++
++/*
++ * Collect connections by PID
++ */
++PyObject *
++psutil_proc_connections(PyObject *self, PyObject *args)
++{
++ PyObject *py_retlist = PyList_New(0);
++ PyObject *py_tuple = NULL;
++ PyObject *py_laddr = NULL;
++ PyObject *py_raddr = NULL;
++ pid_t pid;
++
++ if (! PyArg_ParseTuple(args, "l", &pid))
++ return NULL;
++
++ if (py_retlist == NULL)
++ return NULL;
++
++ kiflist_init();
++ kpcblist_init();
++ get_info(ALL);
++
++ struct kif *k;
++ SLIST_FOREACH(k, &kihead, kifs) {
++ struct kpcb *kp;
++ if (k->kif->ki_pid == pid) {
++ SLIST_FOREACH(kp, &kpcbhead, kpcbs) {
++ if (k->kif->ki_fdata == kp->kpcb->ki_sockaddr) {
++ pid_t pid;
++ int32_t fd;
++ int32_t family;
++ int32_t type;
++ char laddr[PATH_MAX];
++ int32_t lport;
++ char raddr[PATH_MAX];
++ int32_t rport;
++ int32_t status;
++
++ pid = k->kif->ki_pid;
++ fd = k->kif->ki_fd;
++ family = kp->kpcb->ki_family;
++ type = kp->kpcb->ki_type;
++ if (kp->kpcb->ki_family == AF_INET) {
++ struct sockaddr_in *sin_src =
++ (struct sockaddr_in *)&kp->kpcb->ki_src;
++ struct sockaddr_in *sin_dst =
++ (struct sockaddr_in *)&kp->kpcb->ki_dst;
++ if (inet_ntop(AF_INET, &sin_src->sin_addr, laddr,
++ sizeof(laddr)) != NULL)
++ lport = ntohs(sin_src->sin_port);
++ py_laddr = Py_BuildValue("(si)", laddr, lport);
++ if (inet_ntop(AF_INET, &sin_dst->sin_addr, raddr,
++ sizeof(raddr)) != NULL)
++ rport = ntohs(sin_dst->sin_port);
++ py_raddr = Py_BuildValue("(si)", raddr, rport);
++ if (kp->kpcb->ki_type == SOCK_STREAM) {
++ status = kp->kpcb->ki_tstate;
++ } else {
++ status = PSUTIL_CONN_NONE;
++ }
++
++ py_tuple = Py_BuildValue("(iiiNNi)", fd, AF_INET,
++ type, py_laddr, py_raddr, status);
++ if (!py_tuple) {
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ } else if (kp->kpcb->ki_family == AF_INET6) {
++ struct sockaddr_in6 *sin6_src =
++ (struct sockaddr_in6 *)&kp->kpcb->ki_src;
++ struct sockaddr_in6 *sin6_dst =
++ (struct sockaddr_in6 *)&kp->kpcb->ki_dst;
++ if (inet_ntop(AF_INET6, &sin6_src->sin6_addr, laddr,
++ sizeof(laddr)) != NULL)
++ lport = ntohs(sin6_src->sin6_port);
++ py_laddr = Py_BuildValue("(si)", laddr, lport);
++ if (inet_ntop(AF_INET6, &sin6_dst->sin6_addr, raddr,
++ sizeof(raddr)) != NULL)
++ rport = ntohs(sin6_dst->sin6_port);
++ py_raddr = Py_BuildValue("(si)", raddr, rport);
++ if (kp->kpcb->ki_type == SOCK_STREAM) {
++ status = kp->kpcb->ki_tstate;
++ } else {
++ status = PSUTIL_CONN_NONE;
++ }
++
++ py_tuple = Py_BuildValue("(iiiNNi)", fd, AF_INET6,
++ type, py_laddr, py_raddr, status);
++ if (!py_tuple) {
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ } else if (kp->kpcb->ki_family == AF_UNIX) {
++ struct sockaddr_un *sun_src =
++ (struct sockaddr_un *)&kp->kpcb->ki_src;
++ struct sockaddr_un *sun_dst =
++ (struct sockaddr_un *)&kp->kpcb->ki_dst;
++ strcpy(laddr, sun_src->sun_path);
++ strcpy(raddr, sun_dst->sun_path);
++ status = PSUTIL_CONN_NONE;
++
++ py_tuple = Py_BuildValue("(iiissi)", fd, AF_UNIX,
++ type, laddr, raddr, status);
++ if (!py_tuple) {
++ printf("Empty tuple\n");
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ } else if (kp->kpcb->ki_family == AF_UNIX) {
++ struct sockaddr_un *sun_src =
++ (struct sockaddr_un *)&kp->kpcb->ki_src;
++ struct sockaddr_un *sun_dst =
++ (struct sockaddr_un *)&kp->kpcb->ki_dst;
++ strcpy(laddr, sun_src->sun_path);
++ strcpy(raddr, sun_dst->sun_path);
++ status = PSUTIL_CONN_NONE;
++
++ py_tuple = Py_BuildValue("(iiissi)", fd, AF_UNIX,
++ type, laddr, raddr, status);
++ if (!py_tuple) {
++ printf("Empty tuple\n");
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ }
++
++
++ }
++ }}
++ }
++
++ kiflist_clear();
++ kpcblist_clear();
++ return py_retlist;
++
++
++}
++
++
++/*
++ * Collect open file and connections
++ */
++static void
++get_info(int aff)
++{
++ get_files();
++
++ switch (aff) {
++ case INET:
++ get_sockets("net.inet.tcp.pcblist");
++ get_sockets("net.inet.udp.pcblist");
++ get_sockets("net.inet6.tcp6.pcblist");
++ get_sockets("net.inet6.udp6.pcblist");
++ break;
++ case INET4:
++ get_sockets("net.inet.tcp.pcblist");
++ get_sockets("net.inet.udp.pcblist");
++ break;
++ case INET6:
++ get_sockets("net.inet6.tcp6.pcblist");
++ get_sockets("net.inet6.udp6.pcblist");
++ break;
++ case TCP:
++ get_sockets("net.inet.tcp.pcblist");
++ get_sockets("net.inet6.tcp6.pcblist");
++ break;
++ case TCP4:
++ get_sockets("net.inet.tcp.pcblist");
++ break;
++ case TCP6:
++ get_sockets("net.inet6.tcp6.pcblist");
++ break;
++ case UDP:
++ get_sockets("net.inet.udp.pcblist");
++ get_sockets("net.inet6.udp6.pcblist");
++ break;
++ case UDP4:
++ get_sockets("net.inet.udp.pcblist");
++ break;
++ case UDP6:
++ get_sockets("net.inet6.udp6.pcblist");
++ break;
++ case UNIX:
++ get_sockets("net.local.stream.pcblist");
++ get_sockets("net.local.seqpacket.pcblist");
++ get_sockets("net.local.dgram.pcblist");
++ break;
++ case ALL:
++ get_sockets("net.inet.tcp.pcblist");
++ get_sockets("net.inet.udp.pcblist");
++ get_sockets("net.inet6.tcp6.pcblist");
++ get_sockets("net.inet6.udp6.pcblist");
++ get_sockets("net.local.stream.pcblist");
++ get_sockets("net.local.seqpacket.pcblist");
++ get_sockets("net.local.dgram.pcblist");
++ break;
++ }
++ return;
++}
++
++/*
++ * Collect system wide connections by address family filter
++ */
++PyObject *
++psutil_net_connections(PyObject *self, PyObject *args)
++{
++ PyObject *py_retlist = PyList_New(0);
++ PyObject *py_tuple = NULL;
++ PyObject *py_laddr = NULL;
++ PyObject *py_raddr = NULL;
++
++ if (py_retlist == NULL)
++ return NULL;
++
++ kiflist_init();
++ kpcblist_init();
++ get_info(ALL);
++
++ struct kif *k;
++ SLIST_FOREACH(k, &kihead, kifs) {
++ struct kpcb *kp;
++ SLIST_FOREACH(kp, &kpcbhead, kpcbs) {
++ if (k->kif->ki_fdata == kp->kpcb->ki_sockaddr) {
++ pid_t pid;
++ int32_t fd;
++ int32_t family;
++ int32_t type;
++ char laddr[PATH_MAX];
++ int32_t lport;
++ char raddr[PATH_MAX];
++ int32_t rport;
++ int32_t status;
++
++ pid = k->kif->ki_pid;
++ fd = k->kif->ki_fd;
++ family = kp->kpcb->ki_family;
++ type = kp->kpcb->ki_type;
++ if (kp->kpcb->ki_family == AF_INET) {
++ struct sockaddr_in *sin_src =
++ (struct sockaddr_in *)&kp->kpcb->ki_src;
++ struct sockaddr_in *sin_dst =
++ (struct sockaddr_in *)&kp->kpcb->ki_dst;
++ if (inet_ntop(AF_INET, &sin_src->sin_addr, laddr,
++ sizeof(laddr)) != NULL)
++ lport = ntohs(sin_src->sin_port);
++ py_laddr = Py_BuildValue("(si)", laddr, lport);
++ if (inet_ntop(AF_INET, &sin_dst->sin_addr, raddr,
++ sizeof(raddr)) != NULL)
++ rport = ntohs(sin_dst->sin_port);
++ py_raddr = Py_BuildValue("(si)", raddr, rport);
++ if (kp->kpcb->ki_type == SOCK_STREAM) {
++ status = kp->kpcb->ki_tstate;
++ } else {
++ status = PSUTIL_CONN_NONE;
++ }
++
++ py_tuple = Py_BuildValue("(iiiNNii)", fd, AF_INET,
++ type, py_laddr, py_raddr, status, pid);
++ if (!py_tuple) {
++ printf("Empty tuple\n");
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ } else if (kp->kpcb->ki_family == AF_INET6) {
++ struct sockaddr_in6 *sin6_src =
++ (struct sockaddr_in6 *)&kp->kpcb->ki_src;
++ struct sockaddr_in6 *sin6_dst =
++ (struct sockaddr_in6 *)&kp->kpcb->ki_dst;
++ if (inet_ntop(AF_INET6, &sin6_src->sin6_addr, laddr,
++ sizeof(laddr)) != NULL)
++ lport = ntohs(sin6_src->sin6_port);
++ py_laddr = Py_BuildValue("(si)", laddr, lport);
++ if (inet_ntop(AF_INET6, &sin6_dst->sin6_addr, raddr,
++ sizeof(raddr)) != NULL)
++ rport = ntohs(sin6_dst->sin6_port);
++ py_raddr = Py_BuildValue("(si)", raddr, rport);
++ if (kp->kpcb->ki_type == SOCK_STREAM) {
++ status = kp->kpcb->ki_tstate;
++ } else {
++ status = PSUTIL_CONN_NONE;
++ }
++
++ py_tuple = Py_BuildValue("(iiiNNii)", fd, AF_INET6,
++ type, py_laddr, py_raddr, status, pid);
++ if (!py_tuple) {
++ printf("Empty tuple\n");
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ } else if (kp->kpcb->ki_family == AF_UNIX) {
++ struct sockaddr_un *sun_src =
++ (struct sockaddr_un *)&kp->kpcb->ki_src;
++ struct sockaddr_un *sun_dst =
++ (struct sockaddr_un *)&kp->kpcb->ki_dst;
++ strcpy(laddr, sun_src->sun_path);
++ strcpy(raddr, sun_dst->sun_path);
++ status = PSUTIL_CONN_NONE;
++
++ py_tuple = Py_BuildValue("(iiissii)", fd, AF_UNIX,
++ type, laddr, raddr, status, pid);
++ if (!py_tuple) {
++ printf("Empty tuple\n");
++ return 0;
++ }
++ if (PyList_Append(py_retlist, py_tuple))
++ return 0;
++ }
++
++
++ }
++ }
++ }
++
++ kiflist_clear();
++ kpcblist_clear();
++ return py_retlist;
++}
diff --git a/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.h b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.h
new file mode 100644
index 00000000000..af4a2005a4a
--- /dev/null
+++ b/sysutils/py-psutil/patches/patch-psutil_arch_bsd_netbsd__socks.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-psutil_arch_bsd_netbsd__socks.h,v 1.1 2015/12/01 14:07:36 ryoon Exp $
+
+--- psutil/arch/bsd/netbsd_socks.h.orig 2015-11-29 09:43:19.000000000 +0000
++++ psutil/arch/bsd/netbsd_socks.h
+@@ -0,0 +1,10 @@
++/*
++ * Copyright (c) 2009, Giampaolo Rodola'.
++ * Copyright (c) 2015, Ryo ONODERA.
++ * All rights reserved.
++ * Use of this source code is governed by a BSD-style license that can be
++ * found in the LICENSE file.
++ */
++
++PyObject *psutil_proc_connections(PyObject *, PyObject *);
++PyObject *psutil_net_connections(PyObject *, PyObject *);
diff --git a/sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.c b/sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.c
deleted file mode 100644
index be6e0a0053e..00000000000
--- a/sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.c
+++ /dev/null
@@ -1,296 +0,0 @@
-$NetBSD: patch-psutil_arch_netbsd_process__info.c,v 1.1 2013/10/12 13:32:36 wiz Exp $
-
-Port to NetBSD.
-
---- psutil/arch/netbsd/process_info.c.orig 2013-10-12 13:19:29.000000000 +0000
-+++ psutil/arch/netbsd/process_info.c
-@@ -0,0 +1,289 @@
-+/*
-+ * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
-+ * Use of this source code is governed by a BSD-style license that can be
-+ * found in the LICENSE file.
-+ *
-+ * Helper functions related to fetching process information. Used by _psutil_netbsd
-+ * module methods.
-+ */
-+
-+#include <Python.h>
-+#include <assert.h>
-+#include <errno.h>
-+#include <stdlib.h>
-+#include <stdio.h>
-+#include <string.h>
-+#include <sys/types.h>
-+#include <sys/sysctl.h>
-+#include <sys/param.h>
-+#include <sys/user.h>
-+#include <sys/proc.h>
-+#include <signal.h>
-+
-+#include "process_info.h"
-+
-+
-+/*
-+ * Returns a list of all BSD processes on the system. This routine
-+ * allocates the list and puts it in *procList and a count of the
-+ * number of entries in *procCount. You are responsible for freeing
-+ * this list (use "free" from System framework).
-+ * On success, the function returns 0.
-+ * On error, the function returns a BSD errno value.
-+ */
-+int
-+psutil_get_proc_list(struct kinfo_proc2 **procList, size_t *procCount)
-+{
-+ int err;
-+ struct kinfo_proc2 * result;
-+ int done;
-+ static const int name[] = { CTL_KERN, KERN_PROC2, KERN_PROC_ALL, 0 };
-+ // Declaring name as const requires us to cast it when passing it to
-+ // sysctl because the prototype doesn't include the const modifier.
-+ size_t length;
-+
-+ assert( procList != NULL);
-+ assert(*procList == NULL);
-+ assert(procCount != NULL);
-+
-+ *procCount = 0;
-+
-+ /*
-+ * We start by calling sysctl with result == NULL and length == 0.
-+ * That will succeed, and set length to the appropriate length.
-+ * We then allocate a buffer of that size and call sysctl again
-+ * with that buffer. If that succeeds, we're done. If that fails
-+ * with ENOMEM, we have to throw away our buffer and loop. Note
-+ * that the loop causes use to call sysctl with NULL again; this
-+ * is necessary because the ENOMEM failure case sets length to
-+ * the amount of data returned, not the amount of data that
-+ * could have been returned.
-+ */
-+ result = NULL;
-+ done = 0;
-+ do {
-+ assert(result == NULL);
-+ // Call sysctl with a NULL buffer.
-+ length = 0;
-+ err = sysctl((int *)name, (sizeof(name) / sizeof(*name)) - 1,
-+ NULL, &length, NULL, 0);
-+ if (err == -1)
-+ err = errno;
-+
-+ // Allocate an appropriately sized buffer based on the results
-+ // from the previous call.
-+ if (err == 0) {
-+ result = malloc(length);
-+ if (result == NULL)
-+ err = ENOMEM;
-+ }
-+
-+ // Call sysctl again with the new buffer. If we get an ENOMEM
-+ // error, toss away our buffer and start again.
-+ if (err == 0) {
-+ err = sysctl((int *) name, (sizeof(name) / sizeof(*name)) - 1,
-+ result, &length, NULL, 0);
-+ if (err == -1)
-+ err = errno;
-+ if (err == 0) {
-+ done = 1;
-+ }
-+ else if (err == ENOMEM) {
-+ assert(result != NULL);
-+ free(result);
-+ result = NULL;
-+ err = 0;
-+ }
-+ }
-+ } while (err == 0 && ! done);
-+
-+ // Clean up and establish post conditions.
-+ if (err != 0 && result != NULL) {
-+ free(result);
-+ result = NULL;
-+ }
-+
-+ *procList = result;
-+ *procCount = length / sizeof(struct kinfo_proc2);
-+
-+ assert((err == 0) == (*procList != NULL));
-+ return err;
-+}
-+
-+
-+char
-+*psutil_get_cmd_path(long pid, size_t *pathsize)
-+{
-+#if defined(__FreeBSD__)
-+ int mib[4];
-+ char *path;
-+ size_t size = 0;
-+
-+ /*
-+ * Make a sysctl() call to get the raw argument space of the process.
-+ */
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC2;
-+ mib[2] = KERN_PROC_PATHNAME;
-+ mib[3] = pid;
-+
-+ // call with a null buffer first to determine if we need a buffer
-+ if (sysctl(mib, 4, NULL, &size, NULL, 0) == -1) {
-+ return NULL;
-+ }
-+
-+ path = malloc(size);
-+ if (path == NULL) {
-+ PyErr_NoMemory();
-+ return NULL;
-+ }
-+
-+ *pathsize = size;
-+ if (sysctl(mib, MIB_LEN, path, &size, NULL, 0) == -1) {
-+ free(path);
-+ return NULL; /* Insufficient privileges */
-+ }
-+
-+ return path;
-+#else
-+ /* not supported */
-+ return NULL;
-+#endif
-+}
-+
-+
-+/*
-+ * XXX no longer used; it probably makese sense to remove it.
-+ * Borrowed from psi Python System Information project
-+ *
-+ * Get command arguments and environment variables.
-+ *
-+ * Based on code from ps.
-+ *
-+ * Returns:
-+ * 0 for success;
-+ * -1 for failure (Exception raised);
-+ * 1 for insufficient privileges.
-+ */
-+char
-+*psutil_get_cmd_args(long pid, size_t *argsize)
-+{
-+ int mib[4], argmax;
-+ size_t size = sizeof(argmax);
-+ char *procargs = NULL;
-+
-+ /* Get the maximum process arguments size. */
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_ARGMAX;
-+
-+ size = sizeof(argmax);
-+ if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1)
-+ return NULL;
-+
-+ /* Allocate space for the arguments. */
-+ procargs = (char *)malloc(argmax);
-+ if (procargs == NULL) {
-+ PyErr_NoMemory();
-+ return NULL;
-+ }
-+
-+ /*
-+ * Make a sysctl() call to get the raw argument space of the process.
-+ */
-+ mib[0] = CTL_KERN;
-+ mib[1] = KERN_PROC;
-+ mib[2] = KERN_PROC_ARGS;
-+ mib[3] = pid;
-+
-+ size = argmax;
-+ if (sysctl(mib, 4, procargs, &size, NULL, 0) == -1) {
-+ free(procargs);
-+ return NULL; /* Insufficient privileges */
-+ }
-+
-+ // return string and set the length of arguments
-+ *argsize = size;
-+ return procargs;
-+}
-+
-+
-+/* returns the command line as a python list object */
-+PyObject*
-+psutil_get_arg_list(long pid)
-+{
-+ char *argstr = NULL;
-+ int pos = 0;
-+ size_t argsize = 0;
-+ PyObject *retlist = Py_BuildValue("[]");
-+ PyObject *item = NULL;
-+
-+ if (pid < 0) {
-+ return retlist;
-+ }
-+
-+ argstr = psutil_get_cmd_args(pid, &argsize);
-+ if (argstr == NULL) {
-+ goto error;
-+ }
-+
-+ // args are returned as a flattened string with \0 separators between
-+ // arguments add each string to the list then step forward to the next
-+ // separator
-+ if (argsize > 0) {
-+ while(pos < argsize) {
-+ item = Py_BuildValue("s", &argstr[pos]);
-+ if (!item)
-+ goto error;
-+ if (PyList_Append(retlist, item))
-+ goto error;
-+ Py_DECREF(item);
-+ pos = pos + strlen(&argstr[pos]) + 1;
-+ }
-+ }
-+
-+ free(argstr);
-+ return retlist;
-+
-+error:
-+ Py_XDECREF(item);
-+ Py_DECREF(retlist);
-+ if (argstr != NULL)
-+ free(argstr);
-+ return NULL;
-+}
-+
-+
-+/*
-+ * Return 1 if PID exists in the current process list, else 0.
-+ */
-+int
-+psutil_pid_exists(long pid)
-+{
-+ int kill_ret;
-+ if (pid < 0) {
-+ return 0;
-+ }
-+
-+ // if kill returns success of permission denied we know it's a valid PID
-+ kill_ret = kill(pid , 0);
-+ if ((0 == kill_ret) || (EPERM == errno)) {
-+ return 1;
-+ }
-+
-+ // otherwise return 0 for PID not found
-+ return 0;
-+}
-+
-+
-+/*
-+ * Set exception to AccessDenied if pid exists else NoSuchProcess.
-+ */
-+int
-+psutil_raise_ad_or_nsp(pid) {
-+ if (psutil_pid_exists(pid) == 0) {
-+ NoSuchProcess();
-+ }
-+ else {
-+ AccessDenied();
-+ }
-+}
diff --git a/sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.h b/sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.h
deleted file mode 100644
index 31b70053e49..00000000000
--- a/sysutils/py-psutil/patches/patch-psutil_arch_netbsd_process__info.h
+++ /dev/null
@@ -1,23 +0,0 @@
-$NetBSD: patch-psutil_arch_netbsd_process__info.h,v 1.1 2013/10/12 13:32:36 wiz Exp $
-
-Port to NetBSD.
-
---- psutil/arch/netbsd/process_info.h.orig 2013-10-12 13:19:29.000000000 +0000
-+++ psutil/arch/netbsd/process_info.h
-@@ -0,0 +1,16 @@
-+/*
-+ * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
-+ * Use of this source code is governed by a BSD-style license that can be
-+ * found in the LICENSE file.
-+ *
-+ * Helper functions related to fetching process information. Used by _psutil_netbsd
-+ * module methods.
-+ */
-+
-+#include <Python.h>
-+
-+int psutil_get_proc_list(struct kinfo_proc2 **procList, size_t *procCount);
-+char *psutil_get_cmd_args(long pid, size_t *argsize);
-+char *psutil_get_cmd_path(long pid, size_t *pathsize);
-+int psutil_pid_exists(long pid);
-+PyObject* psutil_get_arg_list(long pid);
diff --git a/sysutils/py-psutil/patches/patch-setup.py b/sysutils/py-psutil/patches/patch-setup.py
index 822379faa2f..ab0b6987166 100644
--- a/sysutils/py-psutil/patches/patch-setup.py
+++ b/sysutils/py-psutil/patches/patch-setup.py
@@ -1,25 +1,26 @@
-$NetBSD: patch-setup.py,v 1.3 2013/12/07 21:25:24 richard Exp $
+$NetBSD: patch-setup.py,v 1.4 2015/12/01 14:07:37 ryoon Exp $
Port to NetBSD.
---- setup.py.orig 2013-11-20 19:29:05.000000000 +0000
+--- setup.py.orig 2015-11-25 01:20:34.000000000 +0000
+++ setup.py
-@@ -122,6 +122,18 @@ elif sys.platform.startswith("freebsd"):
- libraries=["devstat"]),
- posix_extension,
- ]
+@@ -151,6 +151,19 @@ elif sys.platform.startswith("openbsd"):
+ define_macros=[VERSION_MACRO],
+ libraries=["kvm"])
+ extensions = [ext, posix_extension]
+# NetBSD
+elif sys.platform.startswith("netbsd"):
-+ extensions = [Extension(
-+ '_psutil_netbsd',
-+ sources = [
-+ 'psutil/_psutil_netbsd.c',
-+ 'psutil/_psutil_common.c',
-+ 'psutil/arch/netbsd/process_info.c'
-+ ],
-+ libraries=[]),
-+ posix_extension,
-+ ]
++ ext = Extension(
++ 'psutil._psutil_bsd',
++ sources=[
++ 'psutil/_psutil_bsd.c',
++ 'psutil/_psutil_common.c',
++ 'psutil/arch/bsd/netbsd.c',
++ 'psutil/arch/bsd/netbsd_socks.c',
++ ],
++ define_macros=[VERSION_MACRO],
++ libraries=["kvm"])
++ extensions = [ext, posix_extension]
# Linux
elif sys.platform.startswith("linux"):
- extensions = [Extension(
+ def get_ethtool_macro():
diff --git a/sysutils/py-psutil/patches/patch-test_test__psutil.py b/sysutils/py-psutil/patches/patch-test_test__psutil.py
index 7bf9ddcac25..23140e9d41d 100644
--- a/sysutils/py-psutil/patches/patch-test_test__psutil.py
+++ b/sysutils/py-psutil/patches/patch-test_test__psutil.py
@@ -1,15 +1,16 @@
-$NetBSD: patch-test_test__psutil.py,v 1.3 2014/04/18 19:58:46 wiz Exp $
+$NetBSD: patch-test_test__psutil.py,v 1.4 2015/12/01 14:07:37 ryoon Exp $
Port to NetBSD.
---- test/test_psutil.py.orig 2014-04-08 00:03:00.000000000 +0000
+--- test/test_psutil.py.orig 2015-11-25 01:20:34.000000000 +0000
+++ test/test_psutil.py
-@@ -87,7 +87,7 @@ if WINDOWS:
- WIN_VISTA = (6, 0, 0)
- LINUX = sys.platform.startswith("linux")
+@@ -107,7 +107,8 @@ LINUX = sys.platform.startswith("linux")
OSX = sys.platform.startswith("darwin")
--BSD = sys.platform.startswith("freebsd")
-+BSD = sys.platform.startswith("freebsd") or sys.platform.startswith("netbsd")
+ FREEBSD = sys.platform.startswith("freebsd")
+ OPENBSD = sys.platform.startswith("openbsd")
+-BSD = FREEBSD or OPENBSD
++NETBSD = sys.platform.startswith("netbsd")
++BSD = FREEBSD or OPENBSD or NETBSD
SUNOS = sys.platform.startswith("sunos")
VALID_PROC_STATUSES = [getattr(psutil, x) for x in dir(psutil)
if x.startswith('STATUS_')]