btrfs/187: fix test failure when using bash 5.0+ with debug enabled
[xfstests-dev.git] / tests / btrfs / 187
index b2d3e4f06e5b27daf4c35067aa266c1806b40a5b..7da09abd735dfcf0a4e3243dff9e728ae3fbe20b 100755 (executable)
@@ -64,9 +64,19 @@ dedupe_two_files()
 
 dedupe_files_loop()
 {
-       trap "wait; exit" SIGTERM
-
-       while true; do
+       local stop=0
+
+       # Avoid executing 'wait' inside the trap, because when we receive
+       # SIGTERM we might be already executing the wait command in the while
+       # loop below. When that is the case, bash 5.0+ with debug enabled prints
+       # a warning message that makes the test fail due to a mismatch with the
+       # golden output. That warning message is the following:
+       #
+       # warning: wait_for: recursively setting old_sigint_handler to wait_sigint_handler: running_trap = 16
+       #
+       trap "stop=1" SIGTERM
+
+       while [ $stop -eq 0 ]; do
                for ((i = 1; i <= 5; i++)); do
                        dedupe_two_files &
                done