2022-10-09 19:48:55 +02:00
|
|
|
import system/ansi_c
|
|
|
|
|
2025-01-22 23:13:01 +01:00
|
|
|
export SIG_DFL, SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV
|
2022-10-09 19:48:55 +02:00
|
|
|
|
|
|
|
when not defined(windows):
|
2025-01-22 23:13:01 +01:00
|
|
|
export SIGPIPE, SIGTERM
|
2022-10-09 19:48:55 +02:00
|
|
|
var
|
|
|
|
SIG_IGN* {.importc: "SIG_IGN", header: "<signal.h>".}: cint
|
|
|
|
SIGHUP* {.importc: "SIGHUP", header: "<signal.h>".}: cint
|
|
|
|
SIGQUIT* {.importc: "SIGQUIT", header: "<signal.h>".}: cint
|
2025-01-22 23:13:01 +01:00
|
|
|
else:
|
|
|
|
const SIGTERM* = cint(15)
|
2022-10-09 19:48:55 +02:00
|
|
|
|
|
|
|
type CSighandlerT = proc (a: cint) {.noconv.}
|
|
|
|
|
|
|
|
proc setSignalProc* (`proc`: CSighandlerT, signals: varargs[cint]) =
|
|
|
|
for sig in signals:
|
|
|
|
discard c_signal(sig, `proc`)
|