Skip to content
Browse files

* swank-ecl.lisp (*original-sigint-handler*)

	(install-sigint-handler): Deleted; we directly implement
	call-with-user-break-handler instead.
	(call-with-user-break-handler): New. Correctly interrupt main
	thread instead of newly spawned handle-signal thread on SIGINT.
	(make-interrupt-handler): New helper.
  • Loading branch information...
1 parent 13f6751 commit bdb66815a7c69d4a14f7c7c9759f08e4e24201ce @trittweiler trittweiler committed
Showing with 36 additions and 13 deletions.
  1. +10 −1 ChangeLog
  2. +26 −12 swank-ecl.lisp
View
11 ChangeLog
@@ -1,3 +1,12 @@
+2010-03-10 Tobias C. Rittweiler <tcr@freebits.de>
+
+ * swank-ecl.lisp (*original-sigint-handler*)
+ (install-sigint-handler): Deleted; we directly implement
+ call-with-user-break-handler instead.
+ (call-with-user-break-handler): New. Correctly interrupt main
+ thread instead of newly spawned handle-signal thread on SIGINT.
+ (make-interrupt-handler): New helper.
+
2010-03-09 Stas Boukarev <stassats@gmail.com>
* swank-ccl.lisp (emacs-inspect function): Print closed over variables
@@ -62,7 +71,7 @@
it boils down to SIGNAL-INTERRUPT which uses USE-THREADS-P which
needs a connection.
(install-fd-handler): Adapted accordingly.
- (simple-serve-event): Adapted accordingly. Additionally, remove
+ (simple-serve-requests): Adapted accordingly. Additionally, remove
superfluous WITH-SWANK-PROTOCOL-HANDLER as that's established by
WITH-CONNECTION already.
(simple-repl): Show "abort inferior lisp" restart only if not a
View
38 swank-ecl.lisp
@@ -124,19 +124,33 @@
;;;; Unix Integration
-(defvar *original-sigint-handler* #'si:terminal-interrupt)
-
-(defimplementation install-sigint-handler (handler)
- (declare (function handler))
- (let ((old-handler (symbol-function 'si:terminal-interrupt)))
+;;; If ECL is built with thread support, it'll spawn a helper thread
+;;; executing the SIGINT handler. We do not want to BREAK into that
+;;; helper but into the main thread, though. This is coupled with the
+;;; current choice of NIL as communication-style in so far as ECL's
+;;; main-thread is also the Slime's REPL thread.
+
+(defimplementation call-with-user-break-handler (real-handler function)
+ (let ((old-handler #'si:terminal-interrupt))
(setf (symbol-function 'si:terminal-interrupt)
- (if (eq handler *original-sigint-handler*)
- handler
- (lambda (&rest args)
- (declare (ignore args))
- (funcall handler)
- (continue))))
- old-handler))
+ (make-interrupt-handler real-handler))
+ (unwind-protect (funcall function)
+ (setf (symbol-function 'si:terminal-interrupt) old-handler))))
+
+#+threads
+(defun make-interrupt-handler (real-handler)
+ (let ((main-thread (find 'si:top-level (mp:all-processes)
+ :key #'mp:process-name)))
+ #'(lambda (&rest args)
+ (declare (ignore args))
+ (mp:interrupt-process main-thread real-handler))))
+
+#-threads
+(defun make-interrupt-handler (real-handler)
+ #'(lambda (&rest args)
+ (declare (ignore args))
+ (funcall real-handler)))
+
(defimplementation getpid ()
(si:getpid))

0 comments on commit bdb6681

Please sign in to comment.
Something went wrong with that request. Please try again.