From 0b75afc41522a275b42c5933d2953652bfb15308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Mon, 28 Mar 2022 17:49:54 +0200 Subject: [PATCH] uxnemu: use read() in stdin thread and close(0) at shutdown for the thread to exit --- src/uxnemu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/uxnemu.c b/src/uxnemu.c index 5dfb3b3..05b3dbf 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -1,5 +1,6 @@ #include #include +#include #include "uxn.h" @@ -81,7 +82,7 @@ stdin_handler(void *p) { SDL_Event event; event.type = stdin_event; - while(fread(&event.cbutton.button, 1, 1, stdin) > 0 && SDL_PushEvent(&event) >= 0) + while(read(0, &event.cbutton.button, 1) > 0 && SDL_PushEvent(&event) >= 0) ; return 0; (void)p; @@ -514,6 +515,7 @@ main(int argc, char **argv) if(!loaded && !start(&u, "launcher.rom")) return error("usage", "uxnemu [-s scale] file.rom"); run(&u); + close(0); /* make stdin thread exit */ SDL_Quit(); return 0; }