|
From: Leo B. <l_b...@us...> - 2017-04-19 16:30:56
|
If gnuplot crashes during a plot/draw operation, the user must fix the
problem manually. Presumably, gnuplot_restart() is meant to be used
here, but this can cause a hang (at least with sbcl), so in the past I
have just restarted maxima. But recently I had invested some time in a
session and did not want to restart so I looked a bit deeper.
The following patch tries to programmatically handle the issue. Of the 3
lisps I have available (ecl, gcl, sbcl) both ecl and sbcl signal a
stream-error and we can handle that; gcl signals an
internal-simple-error which seems too generic to handle so it is just
passed on. I don't know what other lisps do with a broken pipe.
I realize that this opens a can of worms and exposes the deficiencies in
the CL streams specs and all the headaches of cross-platform support,
but it seems like we should be able to do better for most/many cases.
diff --git a/src/plot.lisp b/src/plot.lisp
index fe47a3f3f..ba09b30fd 100644
--- a/src/plot.lisp
+++ b/src/plot.lisp
@@ -148,9 +148,18 @@ sin(y)*(10.0+6*cos(x)),
(defun send-gnuplot-command (command)
(if (null *gnuplot-stream*)
(start-gnuplot-process $gnuplot_command))
- (when (not (null command))
- (format *gnuplot-stream* "~a ~%" command)
- (force-output *gnuplot-stream*)))
+ (handler-case (unless (null command)
+ (format *gnuplot-stream* "~a ~%" command)
+ (force-output *gnuplot-stream*))
+ (stream-error (e)
+ ;; allow gnuplot to restart if stream-error
+ ;; ok: sbcl, ecl
+ (warn "~a~%Trying new stream.~%" e)
+ (setq *gnuplot-stream* nil)
+ (send-gnuplot-command command))
+ (error (e)
+ ;; pass along error otherwise
+ (error e))))
--
Leo Butler <l_b...@us...>
SDF Public Access UNIX System - http://sdf.lonestar.org
|