From 40234b1a3c21cd0ef1087bd5b5e9601dd56c4fce Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 28 Apr 2011 12:52:00 +0300 Subject: input: make stdin non-blocking for terminal input getch2.c did not make stdin non-blocking, and relied on only being called after select() had shown readability. Stop relying on that assumption and set stdin to non-blocking mode. Hopefully no relevant platform has problems with this... --- osdep/getch2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'osdep') diff --git a/osdep/getch2.c b/osdep/getch2.c index 4aa09323eb..3369838682 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -55,6 +55,7 @@ #endif #include +#include #include "mp_fifo.h" #include "keycodes.h" @@ -277,10 +278,15 @@ struct termios tio_new; tcgetattr(0,&tio_orig); tio_new=tio_orig; tio_new.c_lflag &= ~(ICANON|ECHO); /* Clear ICANON and ECHO. */ - tio_new.c_cc[VMIN] = 1; + tio_new.c_cc[VMIN] = 0; tio_new.c_cc[VTIME] = 0; tcsetattr(0,TCSANOW,&tio_new); #endif + /* Setting VMIN above should already make terminal non-blocking; but + * that won't work if stdin is not a real terminal. */ + int flags = fcntl(0, F_GETFL); + if (flags != -1) + fcntl(0, F_SETFL, flags | O_NONBLOCK); getch2_status=1; } -- cgit v1.2.3