Reputation: 41
The Computer Algebra System Maxima uses (open-socket)
in order to connect to its frontend (wxMaxima or xMaxima). Afterwards it makes sure that all output is actually passed to the frontend:
(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))
This works fine (with the exceptions that out-of-memory conditions still might be signalled over stdout and that windows sometimes on out-of-memory doesn't want to send "connection lost" messages to the application maxima is connected to, but it is easy to work around this. Unfortunately if the network connection is lost this causes an error message - that (since the error output is bound to the network) causes an error message that causes...
Is there any way to catch a connection loss before this results in an endless loop?
Sorry to ask such a seemingly basic question. But I didn't find a solution for months now and I assume I need the help of an expert.
Upvotes: 2
Views: 72
Reputation: 139381
How a Common Lisp implementation deals with network errors is implementation specific.
Usually an error condition is signalled.
Thus you need to provide a condition handler, which is active while such a problem might appear. You would need to learn about the Common Lisp condition system and how to handle conditions. How this works with streams, sockets, network connections is very implementation specific.
Upvotes: 1