File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ bool user_exit = false;
43
43
const char * host_interface = nullptr ;
44
44
size_t spiffs_kb = 1024 ;
45
45
bool ignore_sigint = false ;
46
+ bool restore_tty = false ;
46
47
47
48
#define STDIN STDIN_FILENO
48
49
@@ -57,17 +58,23 @@ static int mock_start_uart(void)
57
58
settings = initial_settings;
58
59
settings.c_lflag &= ~(ignore_sigint ? ISIG : 0 );
59
60
settings.c_lflag &= ~(ECHO | ICANON);
60
- settings.c_iflag &= ~(ICRNL | INLCR | ISTRIP | IXON );
61
+ settings.c_iflag &= ~(ICRNL | INLCR | ISTRIP | IXON);
61
62
settings.c_oflag |= (ONLCR);
62
63
settings.c_cc [VMIN] = 0 ;
63
64
settings.c_cc [VTIME] = 0 ;
64
65
if (tcsetattr (STDIN, TCSANOW, &settings) < 0 ) return -2 ;
66
+ tty_restore = true ;
65
67
return 0 ;
66
68
}
67
69
68
70
static int mock_stop_uart (void )
69
71
{
70
- if (!isatty (STDIN)) return 0 ;
72
+ if (!restore_tty) return 0 ;
73
+ if (!isatty (STDIN)) {
74
+ perror (" isatty(STDIN)" );
75
+ // system("stty sane"); <- same error message "Inappropriate ioctl for device"
76
+ return 0 ;
77
+ }
71
78
if (tcsetattr (STDIN, TCSANOW, &initial_settings) < 0 ) return -1 ;
72
79
printf (" \e[?25h" ); // show cursor
73
80
return (0 );
You can’t perform that action at this time.
0 commit comments