[Openmcl-devel] Unix signal handling
gb at clozure.com
Tue Jul 6 13:52:09 CDT 2010
On Tue, 6 Jul 2010, Daniel Weinreb wrote:
> You added ccl:*quit-interrupt-hook*, which is called
> on SIGTERM. Does it have these problems?
There's a handler for SIGTERM (and SIGINT and IIRC SIGQUIT)
in the lisp kernel; it just sets a flag in memory indicating
which of those signals have been received since the flag was
Some lisp code that runs a few times a second checks/clears that flag
and interrupts some thread. There are a few hooks that give a little
bit of control over what thread gets interrupted and (in the case of
SIGQUIT/SIGTERM) what function gets called. That's (at most) just a
matter of interrupting a thread via PROCESS-INTERRUPT, and
PROCESS-INTERRUPT tries to be very careful about when/how the target
thread is interrupted.
A more general mechanism would allow you to do something like:
;; This runs on an arbitrary thread at a more-or-less arbitrary
;; time. The implementation has ensured that it's GC-safe to
;; run lisp code now; beyond that, you have enough rope to hang
;; yourself in lots of ways, and you may not be able to safely
;; do too much more than set a flag here.
but that mechanism doesn't exist and would require some implementation
support to even offer the GC-safety that the comment describes.
More information about the Openmcl-devel