Skip to content

Commit

Permalink
Roll forward of 3904ac3 (3904ac3). Fix #4625 by running the test proc…
Browse files Browse the repository at this point in the history
…ess in a sub-shell.

Apparently, nested background processes interfere with SIGINT handling in bash. I don't 100% understand why and how, but I do have a small bash script that demonstrates the problem: script A that spawns a background process, sends it a SIGINT, and verifies it was received. The script works, *unless* run in the background by a process B; this extra layer of backgrounding cause process A's logic to stop working. See experimental/users/olaola/shell/ for examples. See also https://stackoverflow.com/questions/48847722/nested-background-processes-and-sigint-handling

*** Original change description ***

Fixing test-setup.sh occasionally missing stdout/stderr, on systems where "tail --pid" is supported.

The solutions aren't mine, the new test was taken from Ola's unknown commit and the way to avoid race condition courtesy of sethkoehler@

Mitigates #4608 for compatible Linux systems.

TESTED=presubmits, manual shell tests on new bazel
RELNOTES: None
PiperOrigin-RevId: 186312008
  • Loading branch information
olaola authored and katre committed Feb 28, 2018
1 parent 58bf59e commit 8c57326
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ tail -fq --pid $pid -s 0.001 /dev/null &> /dev/null || has_tail=false
if [ "$has_tail" == true ] && [ -z "$no_echo" ]; then
touch "${XML_OUTPUT_FILE}.log"
if [ -z "$COVERAGE_DIR" ]; then
"${TEST_PATH}" "$@" &>"${XML_OUTPUT_FILE}.log" &
("${TEST_PATH}" "$@" &>"${XML_OUTPUT_FILE}.log") &
pid=$!
else
"$1" "$TEST_PATH" "${@:3}" &> "${XML_OUTPUT_FILE}.log" &
("$1" "$TEST_PATH" "${@:3}" &> "${XML_OUTPUT_FILE}.log") &
pid=$!
fi
tail -fq --pid $pid -s 0.001 "${XML_OUTPUT_FILE}.log"
Expand Down

0 comments on commit 8c57326

Please sign in to comment.