summary refs log tree commit diff homepage
path: root/2048.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-10-15 15:55:52 +0000
committerJune McEnroe <june@causal.agency>2021-10-15 15:55:52 +0000
commite206bf6d689cab448f531b74db7cbc7a6cfce9d2 (patch)
treead4e223eea5a25dd6ad802464a1e22ebe6502714 /2048.c
parentBuild chroot only on OpenBSD (diff)
downloadplay-e206bf6d689cab448f531b74db7cbc7a6cfce9d2.tar.gz
play-e206bf6d689cab448f531b74db7cbc7a6cfce9d2.zip
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.
Diffstat (limited to '2048.c')
-rw-r--r--2048.c4
1 files changed, 3 insertions, 1 deletions
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();