summaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-10-19 16:19:24 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-10-19 16:19:24 -0700
commitb44be63a562eba356495f066a7c6ef2c83866c2b (patch)
treeda3e3ced8a811e3c5fead7868afedfb09b0674a3 /tty.c
parent3db8d503319723c8c1a2950fdcc04f7684c8aa82 (diff)
termios should be reset on successful exit.
Still needs to be fixed on an exit due to ^C Thanks @rtandy
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tty.c b/tty.c
index ec32fd7..6939eb9 100644
--- a/tty.c
+++ b/tty.c
@@ -12,6 +12,12 @@ void tty_reset(tty_t *tty){
tcsetattr(tty->fdin, TCSANOW, &tty->original_termios);
}
+void tty_close(tty_t *tty){
+ tty_reset(tty);
+ fclose(tty->fout);
+ close(tty->fdin);
+}
+
void tty_init(tty_t *tty, const char *tty_filename){
tty->fdin = open(tty_filename, O_RDONLY);
tty->fout = fopen(tty_filename, "w");