Make sure terminal output is unbuffered on POSIX systems (#110)
authorjpellegrini <j_p@aleph0.info>
Mon, 4 Apr 2022 00:23:55 +0000 (21:23 -0300)
committerGitHub <noreply@github.com>
Mon, 4 Apr 2022 00:23:55 +0000 (17:23 -0700)
Call setvbuf on terminal initialization in
csrc/posix/pf_io_posix.c. At least on one platform (OpenWRT),
pForth was buffering the characters while the user typed,
instead of echoing them immediately; this fixes that issue.

Fixes #109
Fixes #87

csrc/posix/pf_io_posix.c

index bd0c50e704fa7a8d25cf3433d44526110893dea5..156e8608617c976afca67180820f59735bacec71 100644 (file)
@@ -131,6 +131,10 @@ void sdTerminalInit(void)
         {
             perror("sdTerminalInit: tcsetattr");
         }
+        if (setvbuf(stdout, NULL, _IONBF, (size_t) 0) != 0)
+        {
+            perror("sdTerminalInit: setvbuf");
+        }
     }
 }