summaryrefslogtreecommitdiffstats
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-06-18 22:08:56 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-06-18 22:08:56 +0000
commitc2f40d98403cfa760d04f810915677a55f8623ef (patch)
treed2bb4673d678ad7d20a57cc740c23654b363e151 /tty.c
parente9fc38325605bd01961fa294d20bcb78b28a14e6 (diff)
Better modes for Solaris.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/tty.c b/tty.c
index 6f433990..039e8357 100644
--- a/tty.c
+++ b/tty.c
@@ -1,4 +1,4 @@
-/* $Id: tty.c,v 1.25 2008-06-18 20:58:03 nicm Exp $ */
+/* $Id: tty.c,v 1.26 2008-06-18 22:08:56 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -23,10 +23,8 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
-#define TTYDEFCHARS
-/* glibc requires unistd.h before termios.h for TTYDEFCHARS. */
-#include <unistd.h>
#include <termios.h>
+#include <unistd.h>
#include "tmux.h"
@@ -59,7 +57,7 @@ int
tty_open(struct tty *tty, char **cause)
{
struct termios tio;
- int what;
+ int what, mode;
tty->fd = open(tty->path, O_RDWR|O_NONBLOCK);
if (tty->fd == -1) {
@@ -67,6 +65,11 @@ tty_open(struct tty *tty, char **cause)
return (-1);
}
+ if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
+ fatal("fcntl");
+ if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1)
+ fatal("fcntl");
+
if ((tty->term = tty_find_term(tty->termname, tty->fd, cause)) == NULL)
goto error;
@@ -82,24 +85,13 @@ tty_open(struct tty *tty, char **cause)
if (tcgetattr(tty->fd, &tty->tio) != 0)
fatal("tcgetattr failed");
-#if 0
- /*
- * This fails on some Linuxes with EINVAL. Which is weird since
- * all we do is take stuff out of the defaults...
- */
- memset(&tio, 0, sizeof tio);
- tio.c_iflag = TTYDEF_IFLAG & ~(IXON|IXOFF|ICRNL|INLCR);
- tio.c_oflag = TTYDEF_OFLAG & ~(OPOST|ONLCR|OCRNL|ONLRET);
- tio.c_lflag =
- TTYDEF_LFLAG & ~(IEXTEN|ICANON|ECHO|ECHOE|ECHOKE|ECHOCTL|ISIG);
- tio.c_cflag = TTYDEF_CFLAG;
- memcpy(&tio.c_cc, ttydefchars, sizeof tio.c_cc);
- cfsetspeed(&tio, TTYDEF_SPEED);
-#endif
memcpy(&tio, &tty->tio, sizeof tio);
- tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR);
- tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET);
- tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHOKE|ECHOCTL|ISIG);
+ tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|IUCLC|ISTRIP);
+ tio.c_iflag |= IGNBRK;
+ tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET|OLCUC|OFILL);
+ tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHONL|ECHOCTL|ECHOPRT|ECHOKE|ECHOCTL|ISIG);
+ tio.c_cc[VMIN] = 1;
+ tio.c_cc[VTIME] = 0;
if (tcsetattr(tty->fd, TCSANOW, &tio) != 0)
fatal("tcsetattr failed");