Use RAII for terminal settings

This commit is contained in:
dmiller 2026-06-18 23:26:07 +00:00
parent e997ad74ae
commit 4f4ad965d1
3 changed files with 12 additions and 2 deletions

View file

@ -1899,8 +1899,7 @@ int nmap_main(int argc, char *argv[]) {
else
nbase_set_log(fatal, NULL);
tty_init(); // Put the keyboard in raw mode
TTYState ttystate; // Put the keyboard in raw mode
#ifdef WIN32
// Must come after parse_options because of --unprivileged

View file

@ -246,6 +246,10 @@ void tty_init()
#endif //!win32
TTYState::~TTYState() {
tty_done();
}
/* Catches all of the predefined
keypresses and interpret them, and it will also tell you if you
should print anything. A value of true being returned means a

View file

@ -74,4 +74,11 @@ void tty_init();
calling method should print a status message */
bool keyWasPressed();
/* RAII object for TTY management */
class TTYState {
public:
TTYState() { tty_init(); }
~TTYState(); // calls tty_done()
};
#endif