Still needs to be fixed on an exit due to ^C
Thanks @rtandy
| ... | ... |
@@ -12,6 +12,12 @@ void tty_reset(tty_t *tty){
|
| 12 | 12 |
tcsetattr(tty->fdin, TCSANOW, &tty->original_termios); |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
+void tty_close(tty_t *tty){
|
|
| 16 |
+ tty_reset(tty); |
|
| 17 |
+ fclose(tty->fout); |
|
| 18 |
+ close(tty->fdin); |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 15 | 21 |
void tty_init(tty_t *tty, const char *tty_filename){
|
| 16 | 22 |
tty->fdin = open(tty_filename, O_RDONLY); |
| 17 | 23 |
tty->fout = fopen(tty_filename, "w"); |