lev.on_signal

lev

on_signal(signum, handler) -> true, err

Register a signal handler

Registers a callback to be invoked when the specified signal is delivered. Must be called within lev.run(). The handler receives the signal number as its argument.

The loop calls the handler itself, outside any task. A wait in it raises lev: wait outside a task. A handler that must wait spawns a task.

A second handler for one signal takes the first one's place. A handler stays until the run ends: nil is no handler and raises.

Raises on SIGKILL and SIGSTOP, which no program can catch, and on a number that names no signal. Returns nil, err when the kernel refuses the setup. The handlers and the signal mask are then as they were.