next up previous contents
Next: 6.9.2 Examples of Signal Up: 6.9 Unix Interrupts Previous: 6.9 Unix Interrupts

6.9.1 Changing Interrupt Handlers

 

[Macro]
system:with-enabled-interrupts specs &rest body

This macro should be called with a list of signal specifications, specs. Each element of specs should be a list of two elements: the first should be the Unix signal for which a handler should be established, the second should be a function to be called when the signal is received One or more signal handlers can be established in this way. with-enabled-interrupts establishes the correct signal handlers and then executes the forms in body. The forms are executed in an unwind-protect so that the state of the signal handlers will be restored to what it was before the with-enabled-interrupts was entered. A signal handler function specified as NIL will set the Unix signal handler to the default which is normally either to ignore the signal or to cause a core dump depending on the particular signal.

[Macro]
system:without-interrupts &rest body

It is sometimes necessary to execute a piece a code that can not be interrupted. This macro the forms in body with interrupts disabled. Note that the Unix interrupts are not actually disabled, rather they are queued until after body has finished executing.

[Macro]
system:with-interrupts &rest body

When executing an interrupt handler, the system disables interrupts, as if the handler was wrapped in in a without-interrupts. The macro with-interrupts can be used to enable interrupts while the forms in body are evaluated. This is useful if body is going to enter a break loop or do some long computation that might need to be interrupted.

[Macro]
system:without-hemlock &rest body

For some interrupts, such as SIGTSTP (suspend the Lisp process and return to the Unix shell) it is necessary to leave Hemlock and then return to it. This macro executes the forms in body after exiting Hemlock. When body has been executed, control is returned to Hemlock.

[Function]
system:enable-interrupt signal function

This function establishes function as the handler for signal.

Unless you want to establish a global signal handler, you should use the macro with-enabled-interrupts to temporarily establish a signal handler. enable-interrupt returns the old function associated with the signal.

[Function]
system:ignore-interrupt signal

Ignore-interrupt sets the Unix signal mechanism to ignore signal which means that the Lisp process will never see the signal. Ignore-interrupt returns the old function associated with the signal or nil if none is currently defined.

[Function]
system:default-interrupt signal

Default-interrupt can be used to tell the Unix signal mechanism to perform the default action for signal. For details on what the default action for a signal is, see section 2 of the ıUnix Programmer's Manual. In general, it is likely to ignore the signal or to cause a core dump.


next up previous contents
Next: 6.9.2 Examples of Signal Up: 6.9 Unix Interrupts Previous: 6.9 Unix Interrupts

Raymond Toy
Mon Jul 14 09:11:27 EDT 1997