Created
May 27, 2020 12:17
-
-
Save luismbo/aa8a3c2599c9690d001ecf81629d7ab6 to your computer and use it in GitHub Desktop.
Redirect stdout to REPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CL-USER> (multiple-value-bind (read write) (sb-unix:unix-pipe) | |
(let ((read-stream (sb-sys:make-fd-stream read :buffering :line))) | |
(sb-thread:make-thread (lambda () | |
(loop for line = (read-line read-stream nil nil) | |
while line do (write-line line *standard-output*)))) | |
(sb-posix:dup2 write sb-sys:*stdout*))) | |
1 | |
CL-USER> (progn (cffi:foreign-funcall "puts" :string "COME TO ME STDOUT!" :int) | |
(cffi:foreign-funcall "fflush" :pointer (cffi:null-pointer) :int)) | |
0 | |
COME TO ME STDOUT! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment