reset terminal after ctrl+c
This commit is contained in:
parent
4f21efdf57
commit
7106c83d5d
1 changed files with 12 additions and 0 deletions
12
main.cpp
12
main.cpp
|
@ -2,6 +2,7 @@
|
|||
// Released under Apache License v2.0
|
||||
#include <poll.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
@ -14,6 +15,13 @@
|
|||
#include "terminal.h"
|
||||
#include "error.h"
|
||||
|
||||
struct termios org_tty_opts { 0 };
|
||||
|
||||
void reset_terminal()
|
||||
{
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &org_tty_opts);
|
||||
}
|
||||
|
||||
void loadbin(bus *const b, uint16_t base, const char *const file)
|
||||
{
|
||||
FILE *fh = fopen(file, "rb");
|
||||
|
@ -287,6 +295,10 @@ int main(int argc, char *argv[])
|
|||
resize_terminal();
|
||||
}
|
||||
|
||||
atexit(reset_terminal);
|
||||
|
||||
tcgetattr(STDIN_FILENO, &org_tty_opts);
|
||||
|
||||
struct termios tty_opts_raw { 0 };
|
||||
cfmakeraw(&tty_opts_raw);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &tty_opts_raw);
|
||||
|
|
Loading…
Add table
Reference in a new issue