Browse code

Abort on any tty errors

John Hawthorn authored on 17/09/2014 02:00:09
Showing 1 changed files

  • tty.c index f7032f1..cbf0a85 100644
... ...
@@ -16,9 +16,11 @@ void tty_reset(tty_t *tty){
16 16
 void tty_init(tty_t *tty, const char *tty_filename){
17 17
 	tty->fdin = open(tty_filename, O_RDONLY);
18 18
 	tty->fout = fopen(tty_filename, "w");
19
-	setvbuf(tty->fout, NULL, _IOFBF, 4096);
19
+	if(setvbuf(tty->fout, NULL, _IOFBF, 4096))
20
+		perror("setvbuf");
20 21
 
21
-	tcgetattr(tty->fdin, &tty->original_termios);
22
+	if(tcgetattr(tty->fdin, &tty->original_termios))
23
+		perror("tcgetattr");
22 24
 
23 25
 	struct termios new_termios = tty->original_termios;
24 26
 
... ...
@@ -29,7 +31,8 @@ void tty_init(tty_t *tty, const char *tty_filename){
29 31
 	 */
30 32
 	new_termios.c_lflag &= ~(ICANON | ECHO);
31 33
 
32
-	tcsetattr(tty->fdin, TCSANOW, &new_termios);
34
+	if(tcsetattr(tty->fdin, TCSANOW, &new_termios))
35
+		perror("tcsetattr");
33 36
 
34 37
 	tty_getwinsz(tty);
35 38