From e206bf6d689cab448f531b74db7cbc7a6cfce9d2 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 15 Oct 2021 15:55:52 +0000 Subject: Retry getch() after ERR In the version of ncurses in OpenBSD, the SIGWINCH handler installed by enabling keypad causes the read() inside getch() to fail with EINTR, which getch() doesn't handle, itself returning ERR. --- 2048.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '2048.c') diff --git a/2048.c b/2048.c index 260f67e..d2e44bb 100644 --- a/2048.c +++ b/2048.c @@ -260,7 +260,9 @@ static void drawGameOver(void) { } static bool input(void) { - switch (getch()) { + int ch = getch(); + if (ch == ERR) ch = getch(); + switch (ch) { break; case 'h': case KEY_LEFT: if (left()) spawn(); break; case 'j': case KEY_DOWN: if (down()) spawn(); break; case 'k': case KEY_UP: if (up()) spawn(); -- cgit 1.4.1