(sigil signals)
POSIX Signal Handling
Register Scheme callbacks for OS signals (SIGTERM, SIGINT, etc.). Signal handlers run in scheduler context during the poll cycle, so they are safe to call arbitrary Scheme code.
Usage
(import (sigil signals))
(on-signal 'term (lambda () (cleanup!) (exit 0)))
(on-signal 'usr1 (lambda () (reload-config!)))Supported signals: term, int, hup, usr1, usr2, winch
Exports
on-signalprocedureRegister a callback for a POSIX signal.
Installs a C-level signal handler that sets a volatile flag, and registers the Scheme callback to be invoked when the signal is detected during the scheduler poll cycle.
Supported signal names: term, int, hup, usr1, usr2, winch
Process signals have one owning VM: the first VM that registers a handler owns dispatch until that VM is destroyed. Register handlers in that VM; a registration from another VM raises an error with message "set-signal-handler!: signals belong to another VM". Other VM schedulers cannot consume its flags or drain its wakeup pipe.
(on-signal 'term (lambda () (display "shutting down\n")))check-signals!procedureCheck all registered signals and invoke pending handlers.
Called by the async scheduler after each poll cycle. Safe to call from Scheme context. Each pending signal's handler is invoked once, then the flag is cleared.
%signal-wake-fdvariable(No description)