Catching SIGPIPE
Marius Gerbershagen
marius.gerbershagen at gmail.com
Fri Feb 15 20:30:05 UTC 2019
Dear Gunter,
signal handlers can be installed and queried with the (currently
undocumented) ext:set-signal-handler, ext:get-signal-handler functions:
CL-USER> (ext:set-signal-handler EXT:+SIGPIPE+ 'ext:quit)
QUIT
CL-USER> (ext:get-signal-handler EXT:+SIGPIPE+)
QUIT
The ECL_OPT_TRAP_SIGPIPE option is meant for programs embedding ECL. If
it is enabled, ECL will install the default SIGPIPE handler, which
currently does nothing.
Best regards,
Marius Gerbershagen
Am 15.02.19 um 18:30 schrieb Gunter Königsmann:
> 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.
>
More information about the ecl-devel
mailing list