mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 11:48:53 +08:00
Fixed terminal when exiting mainapp
mainapp was not restoring the original terminal setttings on exit Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Julian Oes
parent
928a31b59a
commit
a844619b35
@@ -64,6 +64,8 @@ typedef int (*px4_main_t)(int argc, char *argv[]);
|
||||
|
||||
static bool _ExitFlag = false;
|
||||
|
||||
static struct termios orig_term;
|
||||
|
||||
extern "C" {
|
||||
void _SigIntHandler(int sig_num);
|
||||
void _SigIntHandler(int sig_num)
|
||||
@@ -157,11 +159,20 @@ static void process_line(string &line, bool exit_on_fail)
|
||||
run_cmd(appargs, exit_on_fail);
|
||||
}
|
||||
|
||||
static void restore_term(void)
|
||||
{
|
||||
cout << "Restoring terminal\n";
|
||||
tcsetattr (0, TCSANOW, &orig_term);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
bool daemon_mode = false;
|
||||
bool chroot_on = false;
|
||||
|
||||
tcgetattr(0, &orig_term);
|
||||
atexit(restore_term);
|
||||
|
||||
struct sigaction sig_int;
|
||||
memset(&sig_int, 0, sizeof(struct sigaction));
|
||||
sig_int.sa_handler = _SigIntHandler;
|
||||
|
||||
Reference in New Issue
Block a user