diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2017-03-02 01:25:51 +0200 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2017-03-02 01:25:51 +0200 |
commit | 3ea197e5df0de834151dccfa0c7f70651741cac9 (patch) | |
tree | c87d2b499578aa906b443e866926aef3b3dbab03 /scripts/t-rex-64 | |
parent | dc905a7dd6c6938b170964d957a0fafb3cb1ac7f (diff) |
t-rex-64: catch exit with trap to restore tty settings
Change-Id: Id336aa95ceff5e958e9bce329c85eb7201772712
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/t-rex-64')
-rwxr-xr-x | scripts/t-rex-64 | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/scripts/t-rex-64 b/scripts/t-rex-64 index c92d48b0..de83c4c8 100755 --- a/scripts/t-rex-64 +++ b/scripts/t-rex-64 @@ -33,11 +33,13 @@ cd $(dirname $0) export LD_LIBRARY_PATH=$PWD +function restore_tty { + stty $saveterm +} + if [ -t 0 ] && [ -t 1 ]; then - export is_tty=true saveterm="$(stty -g)" -else - export is_tty=false + trap restore_tty EXIT fi # if we have a new core run optimized trex @@ -56,12 +58,5 @@ else RESULT=$? fi -if $is_tty; then - stty $saveterm -fi - -if [ $RESULT -ne 0 ]; then - exit $RESULT -fi - +exit $RESULT |