There is a bug to prevent you from quitting FriCAS when you
issue 'CTRL-D' in the REPL.

This is caused by "fgets" in "remote_stdio" in src/lib/sockio-c.c,
used in binary "spadclient".

I replaced it with "read", and try to exit when CTRL-D (EOF)
is encountered.  I'm not sure if my way to quit FriCAS is proper:

        swrite(sock, ")quit", 5, "quit");

I'm no C expert, so comments are welcomed.

diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index 57163eb9..9a56719e 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -805,14 +805,15 @@ remote_stdio(Sock *sock)
       return;
     }
     if (FD_ISSET(0, &rd)) {
-      fgets(buf,1024,stdin);
-      len = strlen(buf);
-      /*
-          gets(buf);
-          len = strlen(buf);
-          *(buf+len) = '\n';
-          *(buf+len+1) = '\0';
-      */
+      len = read(0, buf, 1024);
+      if (len == -1) {
+        perror("read from stdin");
+        return;
+      }
+      if (len == 0) {
+        /* EOF (CTRL-D) received, exit program */
+        swrite(sock, ")quit", 5, "quitting");
+      }
       swrite(sock, buf, len, "writing to remote stdin");
     }
     if (FD_ISSET(sock->socket, &rd)) {

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to