micropython-lib/unix-ffi/signal/signal.py

24 wiersze
364 B
Python
Czysty Zwykły widok Historia

2015-09-09 14:57:13 +00:00
import ffilib
SIG_DFL = 0
SIG_IGN = 1
SIGINT = 2
SIGPIPE = 13
SIGTERM = 15
2015-09-09 14:57:13 +00:00
libc = ffilib.libc()
signal_i = libc.func("i", "signal", "ii")
signal_p = libc.func("i", "signal", "ip")
def signal(n, handler):
if isinstance(handler, int):
return signal_i(n, handler)
import ffi
cb = ffi.callback("v", handler, "i")
return signal_p(n, cb)