signal-hook icon indicating copy to clipboard operation
signal-hook copied to clipboard

Explicit initialization/capture of signals

Open vorner opened this issue 4 years ago • 0 comments

As discussed in #78, the current situation in which a library may „steal“ a signal that usually has a default handler can be undesirable. This should be something that is controlled by the application.

The proposed solution is to initialize signals explicitly. The application would call something like init_signal(SIGTERM, SigConfig::default()). That would take over the signal handler, allow libraries to hook into it and say how the library should deal with default handler (emulate it always ‒ see #81, get rid of it, call it if there are no hooks...).

We also need some backwards-compatible way to make the initialization mandatory ‒ registration would error out if that didn't happen.

However, certain libraries already take advantage of this implicit takeover (I've seen multiple async runtimes to do so for SIGCHLD). Possibly the way forward is to allow implicit initialization for signals that have an empty default signal handler (because then the takeover has no effect on the behaviour).

vorner avatar Jan 03 '21 10:01 vorner