From b5d09cecf16d5473ac60ab2a47e0acc14e676781 Mon Sep 17 00:00:00 2001 From: Jakub Heger Date: Thu, 23 May 2019 12:48:15 +0200 Subject: [PATCH 2/8] testing.sh: improve shell option handling rlWatchdog() sets -m option but didn't restore it. Can cause troubles in rare conditions. --- src/testing.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/testing.sh b/src/testing.sh index eceb402..44b77ca 100644 --- a/src/testing.sh +++ b/src/testing.sh @@ -962,6 +962,9 @@ Returns 0 if the command ends normally, without need to be killed. =cut rlWatchdog() { + # Save current shell options + local shell_options=$(set +o) + set -m local command=$1 local timeout=$2 @@ -980,6 +983,8 @@ rlWatchdog() { /bin/kill -- -$pidsleep sleep 1 rm -f __INTERNAL_FINISHED __INTERNAL_TIMEOUT + # Restore previous shell options + eval "$shell_options" return 0 elif [ -e __INTERNAL_TIMEOUT ]; then rlLog "Command is still running, I am killing it with $killer" @@ -992,10 +997,12 @@ rlWatchdog() { /bin/kill -$killer -- -$pidcmd sleep 1 rm -f __INTERNAL_FINISHED __INTERNAL_TIMEOUT + eval "$shell_options" return 1 fi sleep 1 done + eval "$shell_options" } # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.21.0