From: Florent Kermarrec Date: Thu, 16 Aug 2018 13:13:27 +0000 (+0200) Subject: sim/verilator: catch ctrl-c on exit and revert default termios settings X-Git-Tag: 24jan2021_ls180~1651 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=650ac1868516a5a606ea6e988be6dea5eb302fb1;p=litex.git sim/verilator: catch ctrl-c on exit and revert default termios settings --- diff --git a/litex/build/sim/verilator.py b/litex/build/sim/verilator.py index 72b7d5e9..ffb89e0f 100644 --- a/litex/build/sim/verilator.py +++ b/litex/build/sim/verilator.py @@ -3,6 +3,7 @@ # License: BSD import os +import sys import subprocess from migen.fhdl.structure import _Fragment @@ -131,9 +132,16 @@ sudo obj_dir/Vdut """ run_script_file = "run_" + build_name + ".sh" tools.write_to_file(run_script_file, run_script_contents, force_unix=True) - r = subprocess.call(["bash", run_script_file]) - if r != 0: - raise OSError("Subprocess failed") + if sys.platform != "win32": + import termios + termios_settings = termios.tcgetattr(sys.stdin.fileno()) + try: + r = subprocess.call(["bash", run_script_file]) + if r != 0: + raise OSError("Subprocess failed") + except: + if sys.platform != "win32": + termios.tcsetattr(sys.stdin.fileno(), termios.TCSAFLUSH, termios_settings) class SimVerilatorToolchain: