Skip to content

Commit

Permalink
Fixed CYGWIN not properly honoring TCSADRAIN/TCSAFLUSH in tcsetattr()…
Browse files Browse the repository at this point in the history
… -- see issue antirez#55 @ github.com/antirez/linenoise
tgaillar committed May 8, 2016
1 parent fd90992 commit 63c9df2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions linenoise.c
Original file line number Diff line number Diff line change
@@ -253,6 +253,11 @@ static int enableRawMode(int fd) {
* We want read to return every single byte, without timeout. */
raw.c_cc[VMIN] = 1; raw.c_cc[VTIME] = 0; /* 1 byte, no timer */

#ifdef __CYGWIN__
// CYGWIN has this annoying thing it does not seem to honor the TCSAFLUSH/TCSADRAIN requirement. Grrrrr!
fflush (NULL); usleep (50000);
#endif

/* put terminal in raw mode after flushing */
if (tcsetattr(fd,TCSAFLUSH,&raw) < 0) goto fatal;
rawmode = 1;
@@ -265,6 +270,11 @@ static int enableRawMode(int fd) {

static void disableRawMode(int fd) {

#ifdef __CYGWIN__
// CYGWIN has this annoying thing it does not seem to honor the TCSAFLUSH/TCSADRAIN requirement. Grrrrr!
fflush (NULL); usleep (50000);
#endif

/* Don't even check the return value as it's too late. */
if (rawmode && tcsetattr(fd,TCSAFLUSH,&orig_termios) != -1)
rawmode = 0;

0 comments on commit 63c9df2

Please sign in to comment.