guicho271828/trivial-signal

Please, state in the docs that "top level" handlers will not work without call to a binding macros.

Opened this issue · 3 comments

The problem with the library is that it shows in the readme, that a signal handler can be set with a top-level form like (setf (signal-handler :term) #'exit-on-signal), but some users on the internet complain that this approach does not work for them. And it is correct, because trivial-signal makes these handlers enabled only inside TRIVIAL-SIGNAL:WITH-SIGNAL-HANDLER or TRIVIAL-SIGNAL:SIGNAL-HANDLER-BIND macros or during the TRIVIAL-SIGNAL:CALL-SIGNAL-HANDLER-BIND function call.

Here I've build a few demos of how trivial-signal can be used: https://github.com/svetlyak40wt/trivial-signal-example probably it would be useful to incorporate their to this repository.

I think it is a bug... It's supposed to work.

It can't work because to make it work you need to call %enable-signal-handler: (defined here) or %enable-all-signal-handlers. This functions calls C function signal to set a signal handler in the system.

Function %enable-all-signal-handlers get called only during the TRIVIAL-SIGNAL:CALL-SIGNAL-HANDLER-BIND.

If you consider this is a bug, then a function like enable-toplevel-handlers should be added to the API.

Thanks for this tip!