From: Jonathan Siegel
Subject: Print after mp:process-run-function crashes command line execution...
Date: 
Message-ID: <g8ZVOdIEHYvgfNorGM8rTd4rFDSi@4ax.com>
Hi,

When I attempt to load a telnet listener and print immediately
afterwards a confirmation string, I get the following error when
loaded from a command prompt:

[········@moe] lisp -L load.cl
*SNIP*
;   Fast loading /home/jonathan/njdev/njsys/telnet.fasl
Warning: An error occurred
         (Unable to print
          #<MULTIPROCESSING:PROCESS telnet-listener @ #x44a2b12>
          readably and *PRINT-READABLY* is true.)
         during the load "load.cl"

I receive no such errors when loaded from the interactive prompt:

[········@moe]$ lisp
USER(1): :ld load
; Loading /home/jonathan/njdev/load.cl
*SNIP*
;   Fast loading /home/jonathan/njdev/njsys/telnet.fasl
Starting telnet listener

The telnet code is from John Foderaro's post, with a custom startup
function:

From telnet.cl:

(defun start-telnet (port)
  (let ((passive (socket:make-socket :connect :passive
				     :local-port port
                                     :reuse-address t)))
    (setq *telnet-server*
      (mp:process-run-function 
       "telnet-listener" 
       #'(lambda (pass)
	   (let ((count 0))
	     (loop
	       (let ((con (socket:accept-connection pass)))
		 (mp:process-run-function 
		  (format nil "tel~d" (incf count))
		  #'(lambda (con)
		      (unwind-protect
			  (tpl::start-interactive-top-level
			   con
			   #'tpl::top-level-read-eval-print-loop
			   nil)
			(ignore-errors (close con :abort t))))
		  con)))))
       passive))))

(if (boundp 'sk-conf:*telnet-server-port*)
    (if (not njsys:*telnet-server*)
	(progn
	  (format t "Starting telnet listener~%")
	  (njsys:start-telnet sk-conf:*telnet-server-port*))
	  ;;(format t "Started telnet listener - process: ~A.~%"
njsys:*telnet-server*))	  
      (format t "Telnet listener already running in this lisp
space.~%"))
  (format t "Telnet listener not created. Add entry to sk-conf.cl
file~%"))

If the commented line reporting the telnet process object is
uncommented, this code will not load from the command prompt as shown
above. When it is commented, the code loads fine. I'm not sure what is
causing this or what steps I can take to track this down further. I
would appreciate hearing any comments or suggestions.

Thanks,
Jonathan
···@scorekeep.com
From: Erik Naggum
Subject: Re: Print after mp:process-run-function crashes command line execution...
Date: 
Message-ID: <3170917489458823@naggum.no>
* Jonathan Siegel <···@scorekeep.com>
| If the commented line reporting the telnet process object is
| uncommented, this code will not load from the command prompt as
| shown above.  When it is commented, the code loads fine.  I'm not
| sure what is causing this or what steps I can take to track this
| down further.  I would appreciate hearing any comments or
| suggestions.

  *print-readably* is true when you run stuff from the command line,
  and nil when you run the same stuff interactively.  Just make sure
  that you set it to nil early in the loading to avoid these problems.

#:Erik
-- 
  If this is not what you expected, please alter your expectations.