summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--osdep/getch2.c8
1 files changed, 7 insertions, 1 deletions
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 <unistd.h>
+#include <fcntl.h>
#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;
}