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)