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