Python bindings for fswait/fswait2
This commit is contained in:
parent
4f4ea53a7f
commit
b7f60c0de9
20
userspace/py/lib/fswait.py
Normal file
20
userspace/py/lib/fswait.py
Normal file
@ -0,0 +1,20 @@
|
||||
import ctypes
|
||||
|
||||
_lib = None
|
||||
|
||||
if not _lib:
|
||||
_lib = ctypes.CDLL('libc.so')
|
||||
_lib.syscall_fswait.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_int)]
|
||||
_lib.syscall_fswait.restype = ctypes.c_int
|
||||
_lib.syscall_fswait2.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_int),ctypes.c_int]
|
||||
_lib.syscall_fswait2.restype = ctypes.c_int
|
||||
|
||||
def fswait(files,timeout=None):
|
||||
fds = (ctypes.c_int * len(files))()
|
||||
for i in range(len(files)):
|
||||
fds[i] = files[i].fileno()
|
||||
if timeout is None:
|
||||
return _lib.syscall_fswait(len(fds),fds)
|
||||
else:
|
||||
return _lib.syscall_fswait2(len(fds),fds,timeout)
|
||||
|
Loading…
Reference in New Issue
Block a user