Automated rollback of commit 39e91a3fa912d636cd9d6f5b3e1b7a44087f8575.

*** Reason for rollback ***

Implicated in breakage of //src/test/shell/integration:client_sigint_test on mac and centos. Rolling back until properly understood.

*** Original change description ***

Fix signal handling in test-setup.sh to properly forward signals to the child process, without relying on a bash bug not present in all environments.

RELNOTES: None.
PiperOrigin-RevId: 302908444
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh
index d2d5f84..098a898 100755
--- a/tools/test/test-setup.sh
+++ b/tools/test/test-setup.sh
@@ -260,23 +260,14 @@
   TEST_PATH="${BASE}.exe"
 fi
 
-childPid="invalid"
-function signal_child {
-  local signal="${1-}"
-  if [ "${signal}" = "SIGTERM" ]; then
-    echo "-- Test timed out at $(date +"%F %T %Z") --"
-  fi
-  kill -s ${signal} $childPid
-}
-
 exitCode=0
 signals="$(trap -l | sed -E 's/[0-9]+\)//g')"
 if [[ "${EXPERIMENTAL_SPLIT_XML_GENERATION}" == "1" ]]; then
-  for signal in $signals; do
-    # SIGCHLD is expected when a subprocess dies
-    [ "${signal}" = "SIGCHLD" ] && continue
-    trap "signal_child ${signal}" ${signal}
-  done
+  # If we trap here, then bash forwards the signal to the subprocess, at least
+  # for bash version 4.4.12(1) on Linux. If we don't trap here, then bash does
+  # not forward the signal. This seems to contradict the bash documentation, and
+  # also seems to contradict bug #7119, which reports the opposite behavior.
+  trap 'echo "-- Test timed out at $(date +"%F %T %Z") --"' SIGTERM
 else
   for signal in $signals; do
     # SIGCHLD is expected when a subprocess dies
@@ -294,19 +285,10 @@
 
 if [[ "${EXPERIMENTAL_SPLIT_XML_GENERATION}" == "1" ]]; then
   if [ -z "$COVERAGE_DIR" ]; then
-    ("${TEST_PATH}" "$@" 2>&1) <&0 &
-    childPid=$!
+    "${TEST_PATH}" "$@" 2>&1 || exitCode=$?
   else
-    ("$1" "$TEST_PATH" "${@:3}" 2>&1) <&0 &
-    childPid=$!
+    "$1" "$TEST_PATH" "${@:3}" 2>&1 || exitCode=$?
   fi
-
-  wait $childPid
-  # If interrupted by a signal, use the signal as the exit code. But allow
-  # the child to actually finish from the signal we sent _it_ via signal_child.
-  # If it already exited, the second wait is a no-op.
-  exitCode=$?
-  wait $childPid
 elif [ "$has_tail" == true ] && [  -z "$no_echo" ]; then
   touch "${XML_OUTPUT_FILE}.log"
   if [ -z "$COVERAGE_DIR" ]; then