summaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tty.c b/tty.c
index 11c6de4..bf2bc83 100644
--- a/tty.c
+++ b/tty.c
@@ -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;