my current attempt to bring this into the new millenium:
import ctypes import time import errno
class timeval(ctypes.Structure): _fields_ = [ ("tv_sec", ctypes.c_int64), ("tv_usec", ctypes.c_int64) ]
libc = ctypes.CDLL('/lib/libc.so.7', use_errno=True) boottime = timeval() if libc.sysctlbyname("kern.boottime", ctypes.byref(boottime), ctypes.sizeof(timeval), None, 0) == -1: print(errno.errorcode[ctypes.get_errno()]) exit(1)
which results in ENOENT
which is rather confusing, given that `sysctl kern.boottime` returns kern.boottime: { sec = 1573656128, usec = 384300 } Wed Nov 13 14:42:08 2019
my current attempt to bring this into the new millenium:
import ctypes
import time
import errno
class timeval( ctypes. Structure) :
_fields_ = [
("tv_sec", ctypes.c_int64),
("tv_usec", ctypes.c_int64)
]
libc = ctypes. CDLL('/ lib/libc. so.7', use_errno=True) me("kern. boottime" , ctypes. byref(boottime) , ctypes. sizeof( timeval) , None, 0) == -1: errno.errorcode [ctypes. get_errno( )])
boottime = timeval()
if libc.sysctlbyna
print(
exit(1)
which results in ENOENT
which is rather confusing, given that `sysctl kern.boottime` returns
kern.boottime: { sec = 1573656128, usec = 384300 } Wed Nov 13 14:42:08 2019