branch: elpa/slime commit 9b2cb0899213f1ed3cebf65fefcde5537e870616 Author: Stas Boukarev <stass...@gmail.com> Commit: Stas Boukarev <stass...@gmail.com>
Fix I/O redirection if *standard-output* is rebound within threads. Fixes #830 --- contrib/swank-repl.lisp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/contrib/swank-repl.lisp b/contrib/swank-repl.lisp index ecf85eec9e..52e8781db3 100644 --- a/contrib/swank-repl.lisp +++ b/contrib/swank-repl.lisp @@ -162,21 +162,25 @@ INPUT OUTPUT IO REPL-RESULTS" (*debug-io* . ,(@ user-io)) (*query-io* . ,(@ user-io)) (*terminal-io* . ,(@ user-io)))))) - (maybe-redirect-global-io conn) (add-hook *connection-closed-hook* 'update-redirection-after-close) (typecase conn (multithreaded-connection - (if swank::*main-thread* - (send swank::*main-thread* - (list :run-on-main-thread - (lambda () - (shiftf (mconn.repl-thread conn) - swank::*main-thread* nil) - (swank::with-io-redirection (conn) - (with-bindings *default-worker-thread-bindings* - (repl-loop conn)))))) - (setf (mconn.repl-thread conn) - (spawn-repl-thread conn "repl-thread"))))) + (cond (swank::*main-thread* + (send swank::*main-thread* + (list :run-on-main-thread + (lambda () + (maybe-redirect-global-io conn) + (shiftf (mconn.repl-thread conn) + swank::*main-thread* nil) + (swank::with-io-redirection (conn) + (with-bindings *default-worker-thread-bindings* + (repl-loop conn))))))) + (t + (maybe-redirect-global-io conn) + (setf (mconn.repl-thread conn) + (spawn-repl-thread conn "repl-thread"))))) + (t + (maybe-redirect-global-io conn))) (list (package-name *package*) (package-string-for-prompt *package*)))))