From 9d72385231fd326bbdc58086d58ec1c37f195685 Mon Sep 17 00:00:00 2001 From: Thomas Hurst Date: Thu, 22 May 2008 20:17:53 +0100 Subject: [PATCH] Move OS version check into main body and have it throw an exception on failure so the import fails. --- terminatorlib/freebsd.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/terminatorlib/freebsd.py b/terminatorlib/freebsd.py index 221d5146..8937dc4d 100644 --- a/terminatorlib/freebsd.py +++ b/terminatorlib/freebsd.py @@ -39,20 +39,19 @@ class kinfo_file(Structure): ('kf_sa_peer', sockaddr_storage), ] +libc = CDLL('libc.so') + +len = c_uint(sizeof(c_uint)) +ver = c_uint(0) + +if (libc.sysctlbyname('kern.osreldate', byref(ver), byref(len), None, 0) < 0): + raise OSError, "sysctlbyname returned < 0" + +# kern.proc.filedesc added for procstat(1) after these __FreeBSD_versions +if ver.value < 700104 and ver.value < 800019: + raise NotImplementedError, "cwd detection requires a recent 7.0-STABLE or 8-CURRENT" def get_process_cwd(pid): - libc = CDLL('libc.so') - - len = c_uint(sizeof(c_uint)) - ver = c_uint(0) - - if (libc.sysctlbyname('kern.osreldate', byref(ver), byref(len), None, 0) < 0): - return None - - # kern.proc.filedesc added for procstat(1) after these __FreeBSD_versions - if ver.value < 700104 and ver.value < 800019: - return None - # /usr/include/sys/sysctl.h # CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC oid = (c_uint * 4)(1, 14, 14, pid)