Scieneer Common Lisp 1.3.9 online documentation

thread:thread-interrupt thread interrupt[Function]

Interrupt thread and cause it to evaluate the interrupt function. The interrupt will be deferred if interrupts are disabled, see sys:without-interrupts. The use of thread:thread-interrupt is not recommended in deployed code, but it may be handy in a development environment.

A thread can not be interrupted while it is executing foreign code and the interrupt will remain pending until the thread returns to lisp code and interrupts are enabled. Since stream operations typically call out to foreign code, a thread blocked on a stream operation is typically not interruptible. Rather than using a thread interrupt to attempt to abort lengthy stream operations, it is recommended that a stream timeout should be used which will generate a synchronous event in the running thread, for example see sys:make-fd-stream which accepts a :timeout argument.

Threads do not safely handle a throw from within interrupts. Code in general is not hardened against such events, and unwind-protect cleanup forms are interruptible so can be aborted. When necessary, it is recommended that threads poll for exit events, such as an exit flag, and arrange to exit gracefully themselves.