unix/input: Flush the prompt after writing it to stdout.

Depending on your setup, stdout might be buffered/line-buffered.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
This commit is contained in:
YAMAMOTO Takashi 2024-02-13 18:46:17 +09:00 committed by Damien George
parent 06cb6b1e9f
commit f9704ce36e

View File

@ -43,6 +43,7 @@ char *prompt(char *p) {
// simple read string // simple read string
static char buf[256]; static char buf[256];
fputs(p, stdout); fputs(p, stdout);
fflush(stdout);
char *s = fgets(buf, sizeof(buf), stdin); char *s = fgets(buf, sizeof(buf), stdin);
if (!s) { if (!s) {
return NULL; return NULL;