Catching SIGPIPE
Gunter Königsmann
gunter at peterpall.de
Fri Feb 15 17:30:27 UTC 2019
Dear all,
Maxima (which is written in lisp) connects to its front-end using a
network socket. stdout and stderr of the lisp are redirected to this
socket.
If the front-end dies unexpectedly this seems to cause ECL to output an
error message which (since it cannot be output) causes an error message
which causes...
On gcl maxima just catches the SIGPIPE signal and exits if the pipe
breaks. ECL offers ECL_OPT_TRAP_SIGPIPE but I don't know what to do with it.
Could anyone give me a hand?
the function that sets up the server is:
(defun setup-client (port &optional (host "localhost"))
;; The following command has to be executed on windows before
;; the connection is opened. If it isn't the first unicode
;; character maxima wants to send causes sbcl to wait indefinitely.
#+sbcl (setf sb-impl::*default-external-format* :utf-8)
(multiple-value-bind (sock condition) (ignore-errors (open-socket host
port))
(unless sock
; It appears that we were unable to open a socket or connect to the
; specified port.
(mtell (intl:gettext "~%Unable to connect Maxima to port ~:M.~%")
port)
(mtell (intl:gettext "Error: ~A~%") condition)
($quit))
#+gcl (setq si::*sigpipe-action* 'si::bye)
(setq *socket-connection* sock)
(setq $old_stderr *error-output*
$old_stdout *standard-output*)
#+ecl (setq *old-stdin* *standard-input*
*old-stdout* *standard-output*
*old-sterr* *error-output*
*old-term-io* *terminal-io*
*old-debug-io* *debug-io*)
(setq *standard-input* sock)
(setq *standard-output* sock)
(setq *error-output* sock)
(setq *terminal-io* sock)
(setq *trace-output* sock)
(format t "pid=~a~%" (getpid))
(force-output sock)
(setq *debug-io* sock))
(values))
Kind regards,
Gunter.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20190215/853834d2/attachment.html>
More information about the ecl-devel
mailing list