2015-09-09 14:57:13 +00:00
|
|
|
import ffilib
|
2015-01-13 23:53:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
SIG_DFL = 0
|
|
|
|
SIG_IGN = 1
|
|
|
|
|
|
|
|
SIGINT = 2
|
|
|
|
SIGPIPE = 13
|
|
|
|
SIGTERM = 15
|
|
|
|
|
2015-09-09 14:57:13 +00:00
|
|
|
libc = ffilib.libc()
|
2015-01-13 23:53:22 +00:00
|
|
|
|
2015-03-09 20:57:23 +00:00
|
|
|
signal_i = libc.func("i", "signal", "ii")
|
|
|
|
signal_p = libc.func("i", "signal", "ip")
|
2015-01-13 23:53:22 +00:00
|
|
|
|
2021-05-27 05:50:04 +00:00
|
|
|
|
2015-01-13 23:53:22 +00:00
|
|
|
def signal(n, handler):
|
|
|
|
if isinstance(handler, int):
|
2015-03-09 20:57:23 +00:00
|
|
|
return signal_i(n, handler)
|
|
|
|
import ffi
|
2021-05-27 05:50:04 +00:00
|
|
|
|
2015-03-09 20:57:23 +00:00
|
|
|
cb = ffi.callback("v", handler, "i")
|
|
|
|
return signal_p(n, cb)
|