Looks OK, go on. This in small irregularity in the protocol,
as "close" now needs double acknowledgement. AFAICS
we would get desired effect in 'get_graph_output' by
issuing any command to vieman, as viewman would respond
only after previous command has finished. But your
change probably is simpler.
Also, by making close synchronous you reduce concurrency
between FRICASsys and viewman, but that probably does not matter.
> diff --git a/src/algebra/view2D.spad b/src/algebra/view2D.spad
> index a9f96f6c..c305ec5f 100644
> --- a/src/algebra/view2D.spad
> +++ b/src/algebra/view2D.spad
> @@ -1020,6 +1020,8 @@ TwoDimensionalViewport () : Exports == Implementation where
> checkViewport viewport =>
> getI(VIEW) -- acknowledge
> viewport.key := 0$I
> + -- receive 100 from viewman, confirm view2D process is closed
> + getI(VIEW)
> void()
>
> coerce viewport ==
> diff --git a/src/algebra/view3D.spad b/src/algebra/view3D.spad
> index bf98b23e..06acc95f 100644
> --- a/src/algebra/view3D.spad
> +++ b/src/algebra/view3D.spad
> @@ -670,6 +670,8 @@ ThreeDimensionalViewport() : Exports == Implementation where
> checkViewport viewport =>
> getI(VIEW) -- acknowledge
> viewport.key := 0$I
> + -- receive 100 from viewman, confirm view3D process is closed
> + getI(VIEW)
> void()
>
> viewpoint (viewport : %) : V ==
> diff --git a/src/graph/viewman/viewman.c b/src/graph/viewman/viewman.c
> index f08cd6b5..44bafac0 100644
> --- a/src/graph/viewman/viewman.c
> +++ b/src/graph/viewman/viewman.c
> @@ -172,6 +172,8 @@ main (void)
> fprintf(stderr,"viewman: closing viewport\n");
> #endif
> closeChildViewport(slot);
> + /* notify Spad process that view2D/view3D process has been closed */
> + send_int(spadSock, 100);
> break;
>
> }; /* switch */
> diff --git a/src/hyper/htinp.c b/src/hyper/htinp.c
> index 7f1729c3..97ab8b45 100644
> --- a/src/hyper/htinp.c
> +++ b/src/hyper/htinp.c
> @@ -347,13 +347,6 @@ get_spad_output(FILE *pfile,char *command,int com_type)
> unescape_string(command);
> }
>
> -/*
> - * THEMOS says: There is a problem here in that we issue the (|close|) and
> - * then go on. If this is the last command, we will soon send a SIGTERM and
> - * the whole thing will collapse maybe BEFORE the writing out has finished.
> - * Fix: Call a Lisp function that checks (with \spadop{key} ps and grep) the
> - * health of the viewport. We do this after the (|close|).
> - */
> void
> get_graph_output(char *command,char *pagename,int com_type)
> {
> @@ -369,10 +362,10 @@ get_graph_output(char *command,char *pagename,int com_type)
> sprintf(buf, "(|processInteractive| '(|write| |%s| \"%s%d\" \"image\") NIL)", "%",
> pagename, example_number);
> send_lisp_command(buf);
> - send_lisp_command("(|setViewportProcess|)");
> - send_lisp_command("(|processInteractive| '(|close| (|%%| -3)) NIL)");
> - send_lisp_command("(|waitForViewport|)");
> + send_lisp_command("(|processInteractive| '(|close| (|%%| -2)) NIL)");
> + send_lisp_command("(|sockSendInt| |$MenuServer| 1)");
> get_int(spad_socket);
> + send_lisp_command("(|setIOindex| (- |$IOindex| 2))");
> }
> static void
> send_command(char *command,int com_type)
> diff --git a/src/interp/util.lisp b/src/interp/util.lisp
> index bb2ae3d6..b87e0552 100644
> --- a/src/interp/util.lisp
> +++ b/src/interp/util.lisp
> @@ -229,24 +229,3 @@ After this function is called the image is clean and can be saved.
>
> ;;; For evaluating categories we need to bind %.
> (defun |c_eval|(u) (let ((% '%)) (declare (special %)) (|eval| u)))
> -
> -;;; Accesed from HyperDoc
> -(defun |setViewportProcess| ()
> - (setq |$ViewportProcessToWatch|
> - (stringimage (CDR
> - (|processInteractive| '(|key| (|%%| -2)) NIL) ))))
> -
> -;;; Accesed from HyperDoc
> -(defun |waitForViewport| ()
> - (progn
> - (do ()
> - ((not (zerop (|run_shell_command|
> - (concat
> - "ps "
> - |$ViewportProcessToWatch|
> - " > /dev/null && sleep 0.1")))))
> - ())
> - (|sockSendInt| |$MenuServer| 1)
> - (|setIOindex| (- |$IOindex| 3))
> - )
> -)
--
Waldek Hebisch