uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 0b75afc41522a275b42c5933d2953652bfb15308
parent f06494477a97be9f22f5037a6f862e420cbfa26b
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Mon, 28 Mar 2022 17:49:54 +0200

uxnemu: use read() in stdin thread and close(0) at shutdown for the thread to exit

Diffstat:
Msrc/uxnemu.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <time.h> +#include <unistd.h> #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; }