oldk1331 wrote:
> I'd like to include this patch, which ignores key CTRL-D.
> Currently CTRL-D may cause garbage output or infinite loop.
> 
> diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
> index 57163eb9..17cc1056 100644
> --- a/src/lib/sockio-c.c
> +++ b/src/lib/sockio-c.c
> @@ -805,15 +805,16 @@ 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';
> -      */
> -      swrite(sock, buf, len, "writing to remote stdin");
> +      len = read(0, buf, 1024);
> +      if (len == -1) {
> +        perror("read from stdin");
> +        return;
> +      }
> +      if (len == 0) {
> +        /* EOF (CTRL-D) received, ignore it for now */
> +      } else {
> +        swrite(sock, buf, len, "writing to remote stdin");
> +      }
>      }
>      if (FD_ISSET(sock->socket, &rd)) {
>        len = sread(sock, buf, 1024, "stdio");

OK, please commit.

-- 
                              Waldek Hebisch

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/E1glaLT-0003hk-Vn%40hera.math.uni.wroc.pl.
For more options, visit https://groups.google.com/d/optout.

Reply via email to