Make emulator restore terminal state when it exits normally
I had code to restore it when it was killed with ctrl-C, but not
in the clean shutdown case.
@@ -410,7 +410,10 @@ int main(int argc, char *argv[])
case MODE_COSIMULATION:
dbg_set_stop_on_fault(proc, false);
if (run_cosimulation(proc, verbose) < 0)
+ {
+ tcsetattr(STDIN_FILENO, TCSANOW, &original_tconfig);
return 1; // Failed
+ }
break;
@@ -425,6 +428,9 @@ int main(int argc, char *argv[])
free(mem_dump_filename);
+ // Restore terminal state
+ tcsetattr(STDIN_FILENO, TCSANOW, &original_tconfig);
+
dump_instruction_stats(proc);
if (block_device_open)
close_block_device();
