summaryrefslogtreecommitdiffstats
path: root/usr.bin/mg/ttyio.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2000-02-27 17:24:12 +0000
committermillert <millert@openbsd.org>2000-02-27 17:24:12 +0000
commita67e42c6074e7aef08f61c86e5f32dfd12cd09cc (patch)
treed05b25637b2656eccc80d65dd1ee5a329ca7947a /usr.bin/mg/ttyio.c
parentMove dobindkey() into extend.c where it belongs. (diff)
downloadwireguard-openbsd-a67e42c6074e7aef08f61c86e5f32dfd12cd09cc.tar.xz
wireguard-openbsd-a67e42c6074e7aef08f61c86e5f32dfd12cd09cc.zip
Better setting of terminal 'raw' mode, cribbed from BSD curses.
We no longer try to put the terminal into 8bit, no parity mode and instead use the TCSASOFT flag to tcsetattr() as per the discussion of this in lib/libocurses/tty.c.
Diffstat (limited to 'usr.bin/mg/ttyio.c')
-rw-r--r--usr.bin/mg/ttyio.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index 2360b8410ef..5870d6cb901 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -47,19 +47,18 @@ ttopen()
if (tcgetattr(0, &ot) < 0)
abort();
nt = ot; /* save entry state */
- nt.c_cc[VMIN] = 1; /* one character read is OK */
- nt.c_cc[VTIME] = 0; /* Never time out. */
+ /* Set terminal to 'raw' mode and ignore a 'break' */
+ nt.c_cc[VMIN] = 1;
+ nt.c_cc[VTIME] = 0;
nt.c_iflag |= IGNBRK;
- nt.c_iflag &= ~( ICRNL | INLCR | ISTRIP | IXON | IXOFF );
+ nt.c_iflag &= ~(BRKINT|PARMRK|INLCR|IGNCR|ICRNL|IXON);
nt.c_oflag &= ~OPOST;
- nt.c_cflag |= CS8; /* allow 8th bit on input */
- nt.c_cflag &= ~PARENB; /* Don't check parity */
- nt.c_lflag &= ~( ECHO | ICANON | ISIG );
+ nt.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
ttysavedp = TRUE;
}
- if (tcsetattr(0, TCSAFLUSH, &nt) < 0)
+ if (tcsetattr(0, TCSASOFT | TCSADRAIN, &nt) < 0)
abort();
ttyactivep = TRUE;
@@ -75,7 +74,7 @@ ttclose()
if(!ttysavedp || !ttyactivep)
return;
ttflush();
- if (tcsetattr(0, TCSAFLUSH, &ot) < 0)
+ if (tcsetattr(0, TCSASOFT | TCSADRAIN, &ot) < 0)
abort();
ttyactivep = FALSE;
}