# os/on-signal
Register a handler closure for an OS signal. Catchable set: `:sigint`,
`:sigterm`, `:sighup`, `:sigquit`, `:sigusr1`, `:sigusr2`, `:sigalrm` —
names are keywords or strings, case-insensitive, with or without the `sig`
prefix. Handlers fire only while the event loop pumps (`[vwait]`,
`[update]`, REPL, servers).
## Syntax
[os/on-signal $signal $handler]
## Parameters
- `$signal` — signal name (`:sigusr1`, `"USR1"`, `:usr1`, …)
- `$handler` — closure `{|ev| ...}` receiving
`%{ :type :signal :signal :sigusr1 :code N :pid N :uid N }` (`:pid`/`:uid`
are the sender's; `:code` is the siginfo code)
## Examples
set got nil [os/on-signal :sigusr1 {|ev| set got $ev~signal}] [os/kill [os/pid] :sigusr1] [update] # pumps the loop once → handler fires echo $got # → :sigusr1 [os/off-signal :sigusr1] # → 1
## Returns
`true` when registered. `%Err{:message}` for an unknown or uncatchable
signal (`sigkill`/`sigstop`), a non-closure handler, a full table (32
handlers), a non-Linux build, or when another runtime in the process already
owns signal delivery. Registering a signal intercepts it: while any handler
exists, Ctrl-C no longer kills.
## See Also
`os/off-signal`, `os/signals`, `os/kill`, `os/pid`