Fixed up the sighandler code some.

This commit is contained in:
shivers 1996-11-07 15:59:31 +00:00
parent cfdc457e2a
commit 5761b6ce03
1 changed files with 14 additions and 5 deletions

View File

@ -95,18 +95,27 @@
;;; continuation), the ENABLED-INTERRUPTS register will be restored to its
;;; previous value.
;;; This handler does nothing -- used when the handler is #f.
(define (noop-sig-handler enabled-interrupts) #f)
(define (set-signal-handler! sig handler)
(let ((nhandler (if (eq? handler #t) ; Get SIG's default handler.
(vector-ref default-handler-vec sig)
handler))
(let ((nhandler (case handler
((#t) (vector-ref default-handler-vec sig))
((#f) noop-sig-handler)
(else handler)))
(int (signal->interrupt sig)))
(with-enabled-interrupts 0
(let ((ohandler (vector-ref interrupt-handlers int)))
(vector-set! interrupt-handlers int nhandler)
ohandler))))
(cond ((eq? ohandler (vector-ref default-handler-vec sig)) #t)
((eq? ohandler noop-sig-handler) #f)
(else ohandler))))))
(define (signal-handler sig)
(vector-ref interrupt-handlers (signal->interrupt sig)))
(let ((handler (vector-ref interrupt-handlers (signal->interrupt sig))))
(cond ((eq? handler (vector-ref default-handler-vec sig)) #t)
((eq? handler noop-sig-handler) #f)
(else handler))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Set the Unix signal handler. One doesn't usually use this; one usually