summaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-09-16 19:00:09 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-09-16 19:00:09 -0700
commit28980ca3281d4c7ee81bf13e1082b7e27c83bd39 (patch)
tree507009efb1e9e4054147699194f1a638a17dc6fc /tty.c
parent4e5bca0b15ae58757d1d294b1ae8dbd9cce67ccc (diff)
Abort on any tty errors
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tty.c b/tty.c
index f7032f1..cbf0a85 100644
--- a/tty.c
+++ b/tty.c
@@ -16,9 +16,11 @@ void tty_reset(tty_t *tty){
void tty_init(tty_t *tty, const char *tty_filename){
tty->fdin = open(tty_filename, O_RDONLY);
tty->fout = fopen(tty_filename, "w");
- setvbuf(tty->fout, NULL, _IOFBF, 4096);
+ if(setvbuf(tty->fout, NULL, _IOFBF, 4096))
+ perror("setvbuf");
- tcgetattr(tty->fdin, &tty->original_termios);
+ if(tcgetattr(tty->fdin, &tty->original_termios))
+ perror("tcgetattr");
struct termios new_termios = tty->original_termios;
@@ -29,7 +31,8 @@ void tty_init(tty_t *tty, const char *tty_filename){
*/
new_termios.c_lflag &= ~(ICANON | ECHO);
- tcsetattr(tty->fdin, TCSANOW, &new_termios);
+ if(tcsetattr(tty->fdin, TCSANOW, &new_termios))
+ perror("tcsetattr");
tty_getwinsz(tty);