This patch is to fix
https://github.com/fricas/fricas/issues/170,
aka when quitting FriCAS, the HyperDoc started by ")hd" should
exit properly.
"viewman" started by ")startGraphics" can exit properly,
see src/graph/viewman/viewman.c line 188:
viewType = get_int(spadSock);
if (viewType == -1) goodbye(-1);
The key here is to detect SpadServer shutdown.
HyperDoc didn't do this check.
Another issue recently discovered by Greg is that
HyperDoc can exit only after mouse passes it.
That's because when you enter a line to FRICASsys,
a SIGUSR2 signal is sent to HyperDoc indicating "EndOfOutput".
This signal will cause system call "select" to fail.
The correct thing to do is using "sselect" to restart
this system call, instead of letting it fail silently.
(Just like what sman.c and seesion.c did.)
BTW, "$PageStuff in hypertex.boot" is recently removed,
so C function "get_new_window" can be removed as well?
- Qian
diff --git a/src/hyper/event.c b/src/hyper/event.c
index a0f0c058..2300a07e 100644
--- a/src/hyper/event.c
+++ b/src/hyper/event.c
@@ -114,7 +114,11 @@ mainEventLoop(void)
handle_event(&event);
}
else {
- select(FD_SETSIZE,(void *)&rd,(void *)&dum1,(void
*)&dum2,NULL);
+ int ret_val = sselect(FD_SETSIZE, &rd, &dum1, &dum2, NULL);
+ if (ret_val == -1) {
+ exitHyperDoc();
+ exit(1);
+ }
if (FD_ISSET(Xcon, &rd) ||
XEventsQueued(gXDisplay, QueuedAfterFlush)) {
XNextEvent(gXDisplay, &event);
@@ -127,10 +131,14 @@ mainEventLoop(void)
* $PageStuff in hypertex.boot
*/
{
- if (100 == get_int(spad_socket)) {
+ int cmd = get_int(spad_socket);
+ if (100 == cmd) {
set_window(gParentWindow->fMainWindow);
make_busy_cursors();
get_new_window();
+ } else if (-1 == cmd) {
+ exitHyperDoc();
+ exit(0);
}
}
/*