diff options
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -20,12 +20,26 @@ void tty_close(tty_t *tty) { void tty_init(tty_t *tty, const char *tty_filename) { tty->fdin = open(tty_filename, O_RDONLY); + if (tty->fdin < 0) { + perror("Failed to open tty"); + exit(EXIT_FAILURE); + } + tty->fout = fopen(tty_filename, "w"); - if (setvbuf(tty->fout, NULL, _IOFBF, 4096)) + if (!tty->fout) { + perror("Failed to open tty"); + exit(EXIT_FAILURE); + } + + if (setvbuf(tty->fout, NULL, _IOFBF, 4096)) { perror("setvbuf"); + exit(EXIT_FAILURE); + } - if (tcgetattr(tty->fdin, &tty->original_termios)) + if (tcgetattr(tty->fdin, &tty->original_termios)) { perror("tcgetattr"); + exit(EXIT_FAILURE); + } struct termios new_termios = tty->original_termios; |