From 650ac1868516a5a606ea6e988be6dea5eb302fb1 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 16 Aug 2018 15:13:27 +0200 Subject: [PATCH] sim/verilator: catch ctrl-c on exit and revert default termios settings --- litex/build/sim/verilator.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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: -- 2.30.2